SSIS - 如何在Script Task中访问系统变量

Con*_*ger 3 variables ssis

任何人都可以建议如何访问/读取脚本组件中的系统变量(例如,我想从脚本组件中的此变量System :: PackageName打包名称)

mil*_*iCH 10

在"脚本任务编辑器"中,在ReadOnlyVariables字段中提供要访问的变量名称(例如System :: PackageName).

从脚本中,在C#示例中,使用:

public void Main()
    {
        bool fireAgain = true;

        // Read the variable
        String PackageName = (String)Dts.Variables["System::PackageName"].Value;

        // Post the value to progress results
        Dts.Events.FireInformation(3, "Package name:", PackageName, "", 0, ref fireAgain);

        Dts.TaskResult = (int)ScriptResults.Success;
    }
Run Code Online (Sandbox Code Playgroud)

结果:

包名为Package