thiswayup
thiswayup

Reputation: 2077

in ssis how do I include a reference to a global variable from a script component?

I have a script component which I need to reference a global variable? I guess I can dtsconfig file. How do I set this and read it back out from my script component?

Upvotes: 3

Views: 3870

Answers (2)

user46795
user46795

Reputation: 2693

You can use

Me.Variables.YourVariableName 

this will work only in script component of Data Flow task. In script task you can use like this:

Dts.Variables("YourVariableName").Value.ToString

All you need is to configure the package variable in the dts config file by specifying the value.

Upvotes: 3

Cade Roux
Cade Roux

Reputation: 89741

From http://blogs.conchango.com/jamiethomson/archive/2005/02/09/964.aspx :

Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
  Public Sub Main()
    Dim vars As Variables
    Dts.VariableDispenser.LockOneForWrite("vMyVar", vars)
    vars(0).Value = "Hello World"
    vars.Unlock()
    Dts.TaskResult = Dts.Results.Success
  End Sub
End Class

Some more discussion:

http://www.developerdotstar.com/community/node/313

http://www.developerdotstar.com/community/node/512

Upvotes: 1

Related Questions