Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSIS - how to access system variables in Script Task

Tags:

variables

ssis

Can anyone please advice how to access/read system variables in Script Component (e.g I want to package name from this variable System::PackageName in Script Component)

like image 970
Conrad Jagger Avatar asked Sep 18 '25 13:09

Conrad Jagger


1 Answers

In the Script Task Editor, provide the variable names you want to access (for example System::PackageName) in the ReadOnlyVariables field.

From the script, in the C# example, use this:

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;
    }

The results:

Package named Package

like image 196
milivojeviCH Avatar answered Sep 21 '25 06:09

milivojeviCH