2014-04-08 12 views
0

所以我在執行SQL任務時做了一些事情,但是我的項目經理寧願在數據流任務中看到它。我將如何在SSIS數據流中實現此查詢?

INSERT INTO [dbo].[lookup_product] 
     ([dim_global_data_source_id] 
     ,[source_product] 
     ,[source_product_type] 
     ,[source_grade] 
     ,[source_gauge] 
     ,[source_width] 
     ) 

SELECT distinct 
     dim_global_data_source_id, 
     product_desc, 
     product_type, 
     grade, 
     gauge, 
     size1 

FROM Staging_informix_Coil_is 
where not exists 
(select source_product 
from lookup_product 
where lookup_product.dim_global_data_source_id =   Staging_informix_Coil_is.dim_global_data_source_id 
and isnull(lookup_product.source_product,'') = isnull(Staging_informix_Coil_is.product_desc,'') 
and lookup_product.source_product_type  = Staging_informix_Coil_is.product_type 
and isnull(lookup_product.source_grade,'') = isnull(Staging_informix_Coil_is.grade,'') 
and isnull(lookup_product.source_gauge,0) = isnull(Staging_informix_Coil_is.gauge,0) 
and isnull(lookup_product.source_width,0) = isnull(Staging_informix_Coil_is.size1,0) 
) 

`

這是查詢。我需要這個工作流程。有人幫我或給我一個樣本

+0

你卡在哪裏? –

+0

精神解析你的查詢,好像你正在試圖將數據加載到一個表中我不知道它已經存在。您是否有要求檢測源和目標之間的變化或者檢查業務密鑰是否足夠? Bingle Andy Leonard ssis增量加載模式或者通過ssis問題看起來更難以找到示例 – billinkc

+0

所有表格都存在。我基本上只需要查找我的臨時表。如果在查找中不存在登臺表的值,則填充查找。我想我被卡住的地方是如何引用查找並檢查記錄是否存在。然後插入這些記錄。 – user3512885

回答

0

我與你的項目經理在這一個。我會創建一個數據流任務。第一個組件是一個OLE DB Source,它只包含你的第一個SELECT(沒有WHERE子句)。

下一個組件將是Lookup,從lookup_product中選擇需要匹配的列。在「列」選項卡上,我將匹配您在WHERE子句中使用的列。在常規選項卡上,我將它設置爲重定向行爲不匹配輸出。

最終組件是OLE DB目標,指向lookup_product表。我會使用No Match輸出將它連接到Lookup。

+0

完美運作。非常感謝Mike Honey。 – user3512885