Skip to main content

Execute Package Task with Package Parameters

Defines a 'ParentPackage' with an Int32 package variable 'MyParentVariable' and an 'ExecutePackage' task that targets 'ChildPackage.dtsx'. The task's 'ParameterBindings' map 'User.MyParentVariable' from the parent to the child package's 'MyParameter' input parameter. The child package declares the matching 'MyParameter' parameter and consumes it in an 'ExecuteSQL' task that inserts the value into a logging table by referencing it via the parameter binding 'ChildPackage.MyParameter'.

To run this end to end, create 'tempdb.dbo.ImportLog' as described in the inline comment and adjust the connection string for 'MyDb' if your test instance is not the local default. This pattern requires SSIS 2012 or later because package parameters did not exist in earlier versions.

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<AdoNetConnection Name="MyDb" ConnectionString="Data Source=.;Initial Catalog=tempdb;Integrated Security=True;" Provider="System.Data.SqlClient.SqlConnection, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" CreateInProject="false" />
</Connections>
<Packages>
<Package Name="ParentPackage">
<Variables>
<Variable Name="MyParentVariable" DataType="Int32">99</Variable>
</Variables>
<Tasks>
<ExecutePackage Name="ChildPkg">
<ExternalProjectPackage Package="ChildPackage.dtsx"/>
<ParameterBindings>
<ParameterBinding Name="MyParameter" VariableName="User.MyParentVariable"/>
</ParameterBindings>
</ExecutePackage>
</Tasks>
</Package>
<Package Name="ChildPackage">
<Parameters>
<Parameter Name="MyParameter" DataType="Int32" IsRequired="true">88</Parameter>
</Parameters>
<Tasks>
<!--
setup this demo:
create table tempdb.dbo.ImportLog ([Filename] varchar(100),[QtyRows] int,[StageTime] datetime)
-->
<ExecuteSQL Name="SQL Log Row Count" ConnectionName="MyDb">
<DirectInput>INSERT INTO dbo.ImportLog ([Filename],[QtyRows],[StageTime]) VALUES('ChildPkg',@QtyRows,SYSDATETIME())</DirectInput>
<Parameters>
<Parameter Name="@QtyRows" DataType="Int32" VariableName="ChildPackage.MyParameter"></Parameter>
</Parameters>
</ExecuteSQL>
</Tasks>
</Package>
</Packages>
</Biml>