我想輸出所有用戶變量及其值的名稱,然後將值存儲在表中。我設法得到了解析變量和它們的值的時刻,但現在它給了我所有的變量(系統和用戶)。此外,我似乎不知道如何將值分配給一個表。任何幫助將不勝感激..以下是我一直想到現在。SSIS包中的輸出變量名稱和值
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
//using System;
////using Microsoft.SqlServer.Dts.Runtime;
namespace ST_81ec2398155247148a7dad513f3be99d.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public void Main()
{
Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
// Load a sample package that contains a variable that sets the file name.
Package pkg = app.LoadPackage(
@"C:\PackagePath" +
@"Template0719.dtsx",
null);
Variables pkgVars = pkg.Variables;
foreach (Variable pkgVar in pkgVars)
{
MessageBox.Show(pkgVar.Name);
MessageBox.Show(pkgVar.Value.ToString());
}
Console.Read();
}
}
}
此腳本僅標識範圍爲包級別的變量。這是你的意圖嗎? – billinkc 2012-07-27 13:58:00
是的。所有用戶變量(僅)在包級別上。 – rvphx 2012-07-27 15:11:51