Sql-Server
如何使用數據流任務在 SSIS 2008 中執行多個選擇語句
我正在使用 SSIS 包將數據從一個數據庫遷移到另一個數據庫,我需要根據下面提到的條件為同一個表編寫多個選擇語句。
我需要添加的實際查詢是
select * from tbldatasets where dataset = 104 and ADDEDTIMESTAMP BETWEEN Convert(datetime, DateAdd(month, -2, Convert(date, GETUTCDATE()))) AND GETUTCDATE() select * from tbldatasets where dataset = 106 and ADDEDTIMESTAMP BETWEEN Convert(datetime, DateAdd(DAY, -10, Convert(date, GETUTCDATE()))) AND GETUTCDATE() select * from tbldatasets where dataset = 107 and ADDEDTIMESTAMP BETWEEN Convert(datetime, DateAdd(MONTH, -1, Convert(date, GETUTCDATE()))) AND GETUTCDATE()
我的 SSIS 包是
在上述情況下,只有第一個查詢正在執行。是否有任何替代方法可以編寫多個選擇語句應該一個接一個地執行,並且還建議我任何用於 SSIS 學習的教程連結。
將此作為您的 SQL 語句。
select * from tbldatasets where dataset = 104 and ADDEDTIMESTAMP BETWEEN Convert(datetime, DateAdd(month, -2, Convert(date, GETUTCDATE()))) AND GETUTCDATE() UNION ALL select * from tbldatasets where dataset = 106 and ADDEDTIMESTAMP BETWEEN Convert(datetime, DateAdd(DAY, -10, Convert(date, GETUTCDATE()))) AND GETUTCDATE() UNION ALL select * from tbldatasets where dataset = 107 and ADDEDTIMESTAMP BETWEEN Convert(datetime, DateAdd(MONTH, -1, Convert(date, GETUTCDATE()))) AND GETUTCDATE()
這將結合您單獨查詢的數據。有關更多資訊,請閱讀 TSQL @ https://msdn.microsoft.com/en-us/library/ms180026.aspx
通過在每個 select 語句後添加 UNION ALL 來更新您的查詢