Sunday, March 26, 2006

SSIS 2005: Returning Values - To a Calling Package from a Child Package

There may be many ways to return values to a calling package from the child package. Today we are going to explore how to do that with the help of a script task from Calling Package.

A child package can be invoked from the calling package through a Script Task. In the following code snippet: A variable of the child package is being initialized and the child package is invoked. After execution of the child package - its variable "OutputVariable" is being read from the calling package.

Public Sub Main()

Dim pkg As String = "D:\SSISWork\Examples\ChildPackage.dtsx"

Dim app As Application = New Application()
Dim p As Package = app.LoadPackage(pkg, Nothing)

// Pass in a value to the Child Package
p.Variables("InputVariable").Value =

// Execute the Child Package
p.Execute()

// Read the Child Package Result Variable
MsgBox(p.Variables("OutputVariable").Value)

Dts.TaskResult = Dts.Results.Success
End Sub

Thursday, March 23, 2006

SQL Server Integration Services : Conditional Execution of First Task

Based on the Question @ http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=312012&SiteID=1 on conditional execution of task - here is a sample solution.

As suggested by Darren - I have used a sequence container as the first task in the package to place the precedence condition. There are 2 script tasks - based on the value assigned to the boolean variable - 'canProceed' either script task 1 & 2 or script task 2 would get executed.

If 'canProceed' = 'True' : Script Task 1 and Script Task 2 will get executed. If 'canProceed' = 'False' : Only Script Task 2 will get executed.

On the Precedence Constraint editor between the Sequence Container and the first Script Task - "Evaluation Operation" is set to "Expression" and Expression is set to @canProceed.

On the Precedence Constraint editor between the Sequence Container and the second Script Task - "Evaluation Operation" is set to "Expression", Expression is set to !@canProceed

On the Precedence Constraint editor between the first Script Task and Second Script Task - "Evaluation Operation" is set to "Constraint" and Value is set to "Success".

The sample solution package would look similar to the following screenshot.

Hope this should help to solve the Conditional Execution of First task problem.