如何在 SSIS 数据流中的两个源之间获取不匹配的数据? [英] How to get unmatched data between two sources in SSIS Data Flow?
问题描述
我有两个数据源,一个 sql 表,一个平面文件 (csv).两个来源具有完全相同的列.示例数据:
I have two data sources, one sql table, one flat file (csv). Both sources have exact same columns. Example Data:
表格:
HCN Name Surname DOB
111 John Black 2013-12-10
222 Jack White 1989-01-14
333 Brian Brown 2000-04-22
平面文件:
HCN Name Surname DOB
111 John Black 2013-12-10
444 Alex Smith 1978-05-16
请注意,列 HCN 是主键.我需要做的是让这些记录包含在表中,但 FlatFile.
Note that the column HCN is the primary key. What I need to do is to get such records included by the table but FlatFile.
预期输出:
HCN Name Surname DOB
222 Jack White 1989-01-14
333 Brian Brown 2000-04-22
我必须在我的 SSIS 包的数据流中执行此操作.我正在下面做以获取匹配的记录(HCN:111),但是我无法弄清楚如何获取不匹配的记录.任何帮助将不胜感激.
I have to do it in Data Flow of my SSIS Package. I am doing below to get the matching records (HCN:111), but how I can get the unmatched ones I could not figure out. Any help would be appreciated.
推荐答案
解决方案 1:查找:
您可以按照以下步骤操作:
SOLUTION 1 : LOOKUP:
You can follows theses steps:
- 添加查找转换
在连接选项卡中,选择您的平面文件连接
在列选项卡中,拖放加入列在常规选项卡中,通过重定向行处理不匹配的条目 - 将不匹配的输出重定向到您的目的地
解决方案 2:左反联接
您可以按照以下步骤操作:
You can follows theses steps:
1 对数据集进行排序/或将源的属性修改为 isSorted= 真
1 Sort datasets / or modifiy the properties of the source to isSorted = true
2 在键上使用 LEFT JOIN,并添加一个包含右侧 id 的新列
2 Use a LEFT JOIN on the key, and add a new column containing the id of the right side
3 在右侧添加条件拆分条件侧ID为空
3 Add a conditional split condition on right side ID is null
然后将CASE 1拆分的数据重定向到您的目的地,您只有左侧的行而没有右侧的对应
Then redirect CASE 1 splited data to your destination, you have only rows from the left side without right side correspondance
这篇关于如何在 SSIS 数据流中的两个源之间获取不匹配的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!