How to apply SSIS Package Configuration using Environment Variable with example? We previously described the list of Package Configurations in the SSIS Package Configuration article.
Before we start the SSIS package configuration, You have to create environment variables. So that you can access them while configuring the package. To create Environment Variables, Go to the Control Panel -> System and Security -> System and click on the Advanced System Settings.
Or Right-click on the My Computer, select the properties, and then select Advanced System Settings will open the System properties.
A simple and elegant way is to type Environment Var in the search bar and select the Edit the System Environment variables option.
The system properties window will open by selecting the Edit the System Environment variables option. Please click on the Environment variables.. button to add a new system variable.
Once you click the Environment variables.. button, the window below will open. Here, you can see all the existing variables and their values. Please click on the New.. button to add a new variable.
As you can see, we are adding Variable Name as EducationDetails and Variable Value as Bachelors.
Next, we are creating one more variable, Variable Name as IncomeVariable, and Variable Value as 70000
Click OK to close the Environment Variables window
SSIS Package Configuration Using Environment Variable Example
Before we start the Package Configuration using an environment variable, let me execute the SSIS package and see what it returns.
Right-click on the control flow region, which will open the context menu. Please select the Package Configurations.. option from it.
Once you select the Package Configurations.., a new Organizer window opens.
Please checkmark the Enable Package Configurations to enable the configurations. Next, click the Add button to add a new SSIS Package Configuration using Environment Variable.
Clicking the Add button will open a wizard. Please check Don’t show this page again to avoid this first page.
Select Configuration type: This is the page we must use to select the configuration type. By default, the XML configuration file is selected by it.
Please refer to the below links for the remaining configurations.
- Parent-Child Package Configuration
- Registry Entry
- Server Configuration
- XML Configuration File
- XML Configuration File in Environment Variable
Here, we are explaining SSIS package configuration using an environment variable. So, let me choose the Environment Variable.
As you can see, we are selecting the EducationDetails variable. Remember, if you don’t find the newly created variable, please close the projects and reopen the BIDS.
Select Target Property: You have to specify the target value here. It may be variable or connection manager settings.
We want to assign this Environment variable to the package variable (InputEducation) value. It means a default value of InputEducation, i.e., Masters Degree, will replace with the Bachelors at run time.
Let me rename it as Education Details Configuration and Click the Finish button to close the wizard.
Now you can see our newly created Environment variable configuration with the Education value.
Use the same approach to add one more package configuration of type Environment Variable. This time we select the IncomeVariable and assign it to the InputYearlyIncome variable (package variable).
Let me assign the name Income Variable Configuration.
Now you can see our newly created Environment variables configurations. Click OK to close the window.?
Let us Run the package to see the result.
The above screenshot shows that it displays the records whose Education is Bachelors, and yearly Income is 70000. It means that the Environment variable values replace package variables values