0

On a Windows system, when I open a DOS command window, I can retrieve the value of operating system environment variable by running this:

C:\Users\me>set MyApplicationEnvironment MyApplicationEnvironment=Staging

I would like to do the same thing in a SSIS environment. Does anyone have any ideas on an optimal approach?

Thanks!

TPV
  • 61
  • 1
  • 5

1 Answers1

1

Create an SSIS variable of type String, MyApplicationEnvrionment

Add a Script Task and specify that the @[User::MyApplicationEnvironment] is a read/write variable.

Assuming C#, the content of the Main would look something like

var env = System.Environment.GetEnvironmentVariable("MyApplicationEnvironment");
if (env != null)
{
    Dts.Variables["User::MyApplicationEnvironment"].Value = env;
}
// TODO: what should happen if the variable is not found

Environment.GetEnvironmentVariable

We assign it to the .Value property of the Dts variable we're looking to update.

billinkc
  • 59,250
  • 9
  • 102
  • 159