Sunday, May 17, 2015

Implementing SSIS Environment Variables

Step 1 : Create Parameters in SSDT

Parameters can be defined at the package level and at the project level. Package-level parameters are visible only to tasks and components within that package. Package parameters are defined in the $Package namespace. Parameters defined at the project level are global—all packages within the project are able to make use of them. Project parameters are defined in the $Project namespace.

In this example i have created two package level parameters and marked as required,as shown in the below image.









Parameters that are marked as Required must have their values specified at runtime. 
Required parameters will not use the design time value when the package runs—a new value must be specified by the caller 
If a parameter's required property is set to false,its design time value will be used if no other value is supplied in run time.

If a parameter is marked as Sensitive, its value will be stored in an encrypted format within the package


Step 2: Parameterize Initial catalog.

In this example i have parameterized the Initial catalog.




























You can also configure Connection string,user name,server name etc













I set the parameter to be Required ,must specify their values at runtime.

After parameterizing the connection manager, save the SSIS solution, and then open
the Parameters tab of the SSIS package pane.You can see the above created parameter in the parameter tab.



Step 3: Deploying Packages to the Package Catalog

Now let’s deploy the project to our SQL Server instance.
The Deployment Wizard is the easiest way to deploy packages to the catalog. You can access
the wizard through SSDT by right-clicking a project and selecting Deploy. 





















After finishing the deployment you can see the deployed project under SSIS DB catalog.












  











Step 4: Create Environments and add variables to it.

Environments allow you to set values to all parameters within projects through their variables at runtime. These environment variables can also be used to configure connection managers so that data can be sourced and loaded according to the simulation you need to run.

To create an environment, navigate to the Environments subfolder where you deployed your project. Right-click the subfolder and select Create Environment.  
I created two environments 'Dev' and 'Prod'



























After creating the environment, you can add variables to it.



























You can also copy the name and value for each parameter from the SSDT parameters window into the environment variable window.























The environment variables can be mapped to the different project and package parameters that are defined.
For this navigating to the project in the Integration Services catalog.
right clicking it,and selecting Configure.


























This page allows you to define the different environments that can pass values to
the project during execution.
Add environments in environment reference tab.

























After the environment reference is set up, you can map project parameter to variables within the environment. 
























Parameters tab allows you to map values of all the parameters contained within the project to the environment variables values. 



No comments:

Post a Comment