且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SSIS Lookup 找不到匹配数据

更新时间:2022-01-10 20:13:29

用户有一个需要用txt更新表数据的功能,用lookup实现,步骤:

 

  1. 循环文件夹的txt文件

  2. Lookup 全部cache目标表数据,比对txt数据和目标表数据

 

SSIS Lookup 找不到匹配数据

3. 如果有match的数据用txt更新目标表

 SSIS Lookup 找不到匹配数据

但是执行每次Match的数据都是0,而txt中确实存在匹配的数据。翻了一下微软的BOL,有一句话很重要:

If there are multiple matches in thereference table, the Lookup transformation returns only the first matchreturned by the lookup query. If multiple matches are found, the Lookup transformation generates anerror or warning only when the transformation has been configured to load allthe reference dataset into the cache. In this case, the Lookuptransformation generates a warning when the transformation detects multiplematches as the transformation fills the cache.

 

后来查了一下我的记录中确实记录都是重复,由于我选择了处理错误的方式“Redirect rows to no match output”,所以数据都到了Not match.

 

之后尝试将重复数据删除就正常了。因为考虑到大部分应用是数据仓库方面的,维度都是为一的,所以很少碰到这个问题。

 

还有一点要注意的是Lookup是大小写敏感的,在处理带有字符数据的时候要注意。

 

另外这个功能用上次提到的处理缓慢变化维的组件也可以实现。


本文转自 lzf328 51CTO博客,原文链接:

http://blog.51cto.com/lzf328/1536480