<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Jim Howey's SQL Server Integration Services Notes</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jamesk/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jamesk/feed.xml</link>
    <description>Jim Howey is a program manager with SQL Server Integration Services.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:50:25 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Using SSIS Script Task to mimic DTS 2000 Execute Package Task variable passing behavior</title>
      <link>https://docs.microsoft.com/archive/blogs/jamesk/using-ssis-script-task-to-mimic-dts-2000-execute-package-task-variable-passing-behavior</link>
      <pubDate>Wed, 21 Dec 2005 13:58:00 GMT</pubDate>
      <dc:creator><![CDATA[jhowey]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jamesk/2005/12/21/using-ssis-script-task-to-mimic-dts-2000-execute-package-task-variable-passing-behavior/</guid>
      <description><![CDATA[In DTS 2000, the execute package task offers the ability to pass variables into the child package,...]]></description>
      <content:encoded><![CDATA[<P>In DTS 2000, the execute package task offers the ability to pass variables into the child package, and retrieve result values from the child package into global variables after execution. For 2005, this mechanism has been replaced by parent package configurations. See links for more detail:</P>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<P><A href="https://msdn2.microsoft.com/en-us/library/ms345179.aspx"><U><FONT face=Arial color=#0000ff size=2>https://msdn2.microsoft.com/en-us/library/ms345179.aspx</FONT></U></A><FONT face=Arial size=2> </FONT></P>
<P><A href="https://sqljunkies.com/WebLog/knight_reign/archive/2004/12/03/5366.aspx"><U><FONT face=Arial color=#0000ff size=2>https://sqljunkies.com/WebLog/knight_reign/archive/2004/12/03/5366.aspx</FONT></U></A><FONT face=Arial size=2> </FONT></P>
<P><A href="https://blogs.conchango.com/jamiethomson/archive/2005/09/01/2096.aspx"><U><FONT face=Arial color=#0000ff size=2>https://blogs.conchango.com/jamiethomson/archive/2005/09/01/2096.aspx</FONT></U></A><FONT face=Arial size=2> </FONT></P></BLOCKQUOTE>
<P dir=ltr style="MARGIN-RIGHT: 0px"><FONT color=#000000>Parent package configurations will handily pass variables into the child package. Things get a little tricky for passing result values back. You can update parent package variables directly from the child package, but this may not work for you. If the child package has an identically named variable, it will hide that in the parent package, and the parent package variable won't get updated. If the child package does not have a matching variable, then the child package won't validate and run when invoked separately, making management more difficult. </FONT></P>
<P dir=ltr style="MARGIN-RIGHT: 0px">One way to&nbsp;pass variables back from child packages is by using script to invoke the child package. I have constructed a pair of packages to illustrate this. </P>
<P dir=ltr style="MARGIN-RIGHT: 0px">The first is called "InvokedByScript.dtsx". It contains two variables: PassedIn and PassedBack. Both are integers. It contains a single script task. On the script tab of the Script Task Editor, I configured ReadOnlyVariables to have the value "PassedIn", while ReadWriteVariables is set to "PassedBack". In the actual script code, I added one line:</P><FONT size=2>
<P><FONT face="Courier New">Dts.Variables(</FONT></FONT><FONT face="Courier New"><FONT color=#800000 size=2>"PassedBack"</FONT><FONT size=2>).Value = 1 + Convert.ToInt32(Dts.Variables(</FONT><FONT color=#800000 size=2>"PassedIn"</FONT><FONT size=2>).Value)</P></FONT></FONT>
<P dir=ltr style="MARGIN-RIGHT: 0px">I saved the package to C:\temp.</P>
<P dir=ltr style="MARGIN-RIGHT: 0px">The second package is called "InvokesInvokedByScript.dtsx". It too contains two variables,&nbsp;PassedIn and PassedBack (both&nbsp;integers), as well as a single script task with ReadOnlyVariables set to "PassedIn" and ReadWriteVariables set to "PassedBack". Added script code looks like this:</P><FONT size=2>
<P></FONT><FONT face="Courier New"><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> pkg </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>String</FONT><FONT size=2> = </FONT></FONT><FONT face="Courier New"><FONT color=#800000 size=2>"C:\temp\InvokedFromScript.dtsx"<BR></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> app </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Application = </FONT><FONT color=#0000ff size=2>New</FONT></FONT><FONT face="Courier New"><FONT size=2> Application()<BR></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> p </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Package = app.LoadPackage(pkg, </FONT><FONT color=#0000ff size=2>Nothing</FONT></FONT><FONT face="Courier New"><FONT size=2>)<BR>p.Variables(</FONT><FONT color=#800000 size=2>"PassedIn"</FONT><FONT size=2>).Value = Dts.Variables(</FONT><FONT color=#800000 size=2>"PassedIn"</FONT></FONT><FONT face="Courier New"><FONT size=2>).Value<BR>p.Execute()<BR>Dts.Variables(</FONT><FONT color=#800000 size=2>"PassedBack"</FONT><FONT size=2>).Value = p.Variables(</FONT><FONT color=#800000 size=2>"PassedBack"</FONT><FONT size=2>).Value</P></FONT></FONT>
<P dir=ltr style="MARGIN-RIGHT: 0px">The code loads the child package, sets a child variable, executes the child package, then updates the parent package variable from the child package variable's value. You can set PassedIn to any value, then set a breakpoint in this code, and use the watch window to observe the four variables as they change during execution.</P>]]></content:encoded>
    </item>
  </channel>
</rss>