Example of execute package task with package parameters

gravatar

Greg Galloway

This snippet shows a parent package, an execute package task, passing a parent package variable to the child package parameter, and then using that child package parameter in an Execute SQL task as a query parameter.

published 03.18.15

last updated 03.18.15


Share

                            


<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>
                        
You are not authorized to comment. A verification email has been sent to your email address. Please verify your account.

Comments

There are no comments yet.