Conrad Jagger
Conrad Jagger

Reputation: 91

SSIS - how to access system variables in Script Task

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)

Upvotes: 3

Views: 14718

Answers (1)

milivojeviCH
milivojeviCH

Reputation: 1608

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

Upvotes: 11

Related Questions