4
我有一個父包需要多次執行相同的子包。爲了讓事情更有趣,每個實例都需要爲傳遞給子包的父參數定義不同的值。從腳本任務執行SSIS包存儲中的子包,帶有扭曲
我使用下面的腳本創建了一個腳本任務:
Microsoft.SqlServer.Dts.Runtime.Application App = new Microsoft.SqlServer.Dts.Runtime.Application();
Package pkg = new Package();
try
{
pkg = App.LoadPackage(@"\\server\SSIS Packages\ChildPackage.dtsx", null);
pkg.Variables["ChildVariableName"].Value = Dts.Variables["AParentVariableName"].Value;
pkg.Execute();
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
Dts.Events.FireError(0, "Run child pkg for parent task", ex.Message, string.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
問題是,我的包都存儲在我的SQL 2008 R2服務器的SSIS包店,我無法弄清楚如何引用它們;我見過的每個代碼示例都是針對物理位置的。這在HA羣集上,因此具有該包的物理位置將難以維護。
因此,我需要(a)找出如何在每次爲此子包啓動一個執行包任務時更改ParentVariable的值,或者(b)弄清楚如何引用SSIS包中的正確包在這一點上,我可以安全地傳遞適當的價值。有人有主意嗎?
我的另一個相關的問題,與一個答案 - http://stackoverflow.com/questions/20671920/pass-variables-to-child-via-c-sharp-script-task – Steam 2013-12-19 21:19:04