THE SQL Server Blog Spot on the Web
Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | Join | Help
in Search

Andy Leonard

SSIS and ETL
Thoughts about Database and Software Development, and the tools of the trade.

Accessing Parent Package Variables In Child Packages... Without Configurations

If you've needed to close the information loop in an SSIS Parent-Child package architecture (also known as Master Package Design), Steve Fibich has a post is for you!

This is the neatest thing I've seen in a long time. Once a child package is called, the parent package variables are available for reference and update - without a single mapping operation. They're just there.

I tried the following:

Create a Parent package with a Script Task and an Execute Package Task. Create a int variable named MyParentVar and accept the default value at 0. 

Configure the script to popup the value of MyParentVar using the code MsgBox(Dts.Variables("MyParentVar").Value.ToString)

Create a Child package and add an Execute SQL Task. Set up any connection manager for the Task and enter "Select 1 as One" in the SQL Statement property. Set the resultset property to Single Row. On the resultset page set ordinal 0 to MyParentVar. In the Execute SQL Task’s properties you have to set DelayValidation to clear the red X circle.

Configure the Execute Package task in the Parent to call the Child package.

Copy the Parent package script task and paste it below the Execute (child) Package task. Wire it up so you get a popup, then the call to the child, then another popup.

Now. Execute the child. Error – there’s not a variable named MyParentVar in the child.

Execute the Parent. Popup 1 says MyParentVar = 0, which it should. Ok that, the child runs and then Popup 2 says MyParentVar = 1. The child updated it – kind of like ByRef arguments in VB.

Steve is using this to pass Object Variables containing datasets back up the pipe. The implications of this little trick are astounding! Good work Steve!

:{> Andy


Published Sunday, September 30, 2007 7:57 PM by andyleonard
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

All Night Coder - Today’s Top Blog Posts on Programming - Powered by SocialRank said:

October 1, 2007 6:09 AM
 

SSIS Junkie said:

As pointed out by Andy , Steve Fibich has a great blog entry explaining how it is possible to pass values

October 6, 2007 12:19 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

About andyleonard

Andy Leonard is a SQL Server MVP, database developer, engineer, husband, and father. Andy lives in Farmville Virginia with his lovely bride Christy Lynn and their three children: Stevie Ray, Emma Grace, and Riley Cooper. Andy's two older children - Manda and Penny - are grown and married. When he's not working (and Andy works a lot), he enjoys spending time with his family, working on their old farmhouse, fishing, and reading older sci-fi series.
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement