ssis - SSIS: How do I query for IDs from 1st database and then select data with only those IDs on 2nd database/data warehouse?
问题描述
SSIS: How do I query for IDs from 1st database and then select data with only those IDs on 2nd database/data warehouse? There are only 12,000 rows I need data on in the 2nd database/data warehouse but the problem is it has 3M+ rows. I need the second SQL query to constrain it to have only the IDs from the 1st query. TIA!
- 1st database query: select distinct ID from tablename1
- 2nd database/datawarehouse query: select * from tablename2 where ID in (IDs from 1st database query)
解决方案
这是我的解决方案,它现在只需 2 分钟而不是 40 分钟即可运行,无需过滤到我需要的 id:
执行 SQL 任务:创建一个表 (table1),其中包含我想用来查询数据仓库/DB #2 的所有不同 ID。还创建另一个表(table2),它将充当第一个数据库中的目标表,其中包含不同的 ID,以及我需要的数据仓库中的列。
(数据流任务)OLE DB SOURCE(从包含不同 ID 的 table1 中选择所有)
(数据流任务)查找:使用设置为完全缓存模式并忽略不匹配条目的查找任务。在数据仓库中查找与 table1 中的 ID 匹配的行(一对一关系)并添加我选择的列。
(数据流任务)OLE DB DESTINATION:将匹配的输出加载到我的目标数据库中的 table2