Use the Values of Variables and Parameters in a Child Package
This procedure describes how to create a package configuration that uses the parent variable configuration type. This configuration type enables a child package that is run from a parent package to access a variable in the parent.
[!UWAGA]
You can also pass values to a child package by configuring the Execute Package Task to map parent package variables or parameters, or project parameters, to child package parameters. For more information, see Execute Package Task.
It is not necessary to create the variable in the parent package before you create the package configuration in the child package. You can add the variable to the parent package at any time, but you must use the exact name of the parent variable in the package configuration. However, before you can create a parent variable configuration, there must be an existing variable in the child package that the configuration can update. For more information about adding and configuring variables, see Add, Delete, Change Scope of User-Defined Variable in a Package.
The scope of the variable in the parent package that is used in a parent variable configuration can be set to the Execute Package task, to the container that has the task, or to the package. If multiple variables with the same name are defined in a package, the variable that is closest in scope to the Execute Package task is used. The closest scope to the Execute Package task is the task itself.
To add a variable to a parent package
In SQL Server Data Tools (SSDT), open the Integration Services project that contains the package to which you want to add a variable to pass to a child package.
In Solution Explorer, double-click the package to open it.
In SSIS Designer, to define the scope of the variable, do one of the following:
To set the scope to the package, click anywhere on the design surface of the Control Flow tab.
To set the scope to a parent container of the Execute Package task, click the container.
To set the scope to the Execute Package task, click the task.
Add and configure a variable.
[!UWAGA]
Select a data type that is compatible with the data that the variable will store.
To save the updated package, click Save Selected Items on the File menu.
To add a variable to a child package
In SQL Server Data Tools (SSDT), open the Integration Services project that contains the package to which you want to add a parent variable configuration.
In Solution Explorer, double-click the package to open it.
In SSIS Designer, to set the scope to the package, click anywhere on the design surface of the Control Flow tab.
Add and configure a variable.
[!UWAGA]
Select a data type that is compatible with the data that the variable will store.
To save the updated package, click Save Selected Items on the File menu.
To add a parent package configuration to a child package
If it is not already open, open the child package in SQL Server Data Tools (SSDT).
Click anywhere on the design surface of the Control Flow tab.
On the SSIS menu, click Package Configurations.
In the Package Configuration Organizer dialog box, select Enable package configuration, and then click Add.
On the welcome page of the Package Configuration Wizard, click Next.
On the Select Configuration Type page, in the Configuration type list, select Parent package variable and do one of the following:
Select Specify configuration settings directly, and then in the Parent variable box, provide the name of the variable in the parent package to use in the configuration.
Ważne: Variable names are case sensitive.
Select or Configuration location is stored in an environment variable, and then in the Environment variable list, select the environmentvariable that contains the name of the variable.
Click Next.
On the Select Target Property page, expand the Variable node, and expand the Properties node of the variable to configure, and then click the property to be set by the configuration.
Click Next.
On the Completing the Wizard page, optionally, modify the default name of the configuration and review the configuration information.
Click Finish to complete the wizard and return to the Package Configuration Organizer dialog box.
In the Package Configuration Organizer dialog box, the Configuration box lists the new configuration.
Click Close.