DTS Output Variables

  • I'm trying to find out if there's a way to pass some variable values from an inner package to the outer package. It seems you can only pass into the child package, but not the other way around. Is that so?

  • You can only return the initial value of a global variable from a DTS package executed via an Execute Package Task.  In other words, if the value of the global variable changes during the execution of the child package, you won't be able to retrieve that value.

    To see the initial value, open your Execute Package task and go to the Inner Package Global Variables tab.  Select the global variable you want to see the value of.  Once selected, you'll see the value of the variable.  You can also retrieve this in an ActiveX script task (but the global variable has to be selected on this tab).  In my example, the global variable from the package being executed in the Execute Package task is named RetVal.

    Function Main()

     

     Dim objTask 

     Set objTask = DTSGlobalVariables.Parent.Tasks("DTSTask_DTSExecutePackageTask_1").CustomTask

     MsgBox objTask.GlobalVariables("RetVal").Value

     Set objTask = Nothing

     Main = DTSTaskExecResult_Success

    End Function

     

  • That sucks! But it's interesting to know there's at least a way to access the initial value in the child package.

    Thanks, Erik!

  • If you really need to access final value of the the global variable from the child package, why not update a table as the last step of the child package then query the same table in the parent package?

    CREATE TABLE [GlobalVariableValues] (

     [PackageName] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

     [VariableName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

     [VariableValue] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     CONSTRAINT [PK_GlobalVariableValues] PRIMARY KEY  CLUSTERED

     (

      [PackageName],

      [VariableName]

    &nbsp  ON [PRIMARY]

    ) ON [PRIMARY]

    GO

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply