Thursday, November 22, 2012 #

SSIS Catalog: How to use environment in every type of package execution

Here is a good blog on how to create a SSIS Catalog and setting up environments.

Here I will summarize 3 ways I know so far to execute a package while using variables set up in SSIS Catalog environment.

First way, we have SSIS project having reference to environment, and having one of the project parameter using a value set up in the environment called "Development".  With this set up, you are limited to calling the packages by right-clicking on the packages in the SSIS catalog list and select Execute, but you are free to choose absolute or relative path of the environment.

The following screenshot shows the 2 available paths to your SSIS environments.  Personally, I use absolute path because of Option 3, just to keep everything simple for myself.

The second option is to call through SQL Job.  This does require you to configure your project to already reference an environment and use its variable.  When a job step is set up, the configuration part will require you to select that reference again.  This is more useful when you want to automate the same package that needs to be run in different environments.

The third option is the most important to me as I have a SSIS framework that calls hundreds of packages.  The main part of the stored procedure is in this post (  But the top part had to be modified to include the logic to use environment reference.

CREATE PROCEDURE [AUDIT].[LaunchPackageExecutionInSSISCatalog]
@PackageName NVARCHAR(255)
, @ProjectFolder NVARCHAR(255)
, @ProjectName NVARCHAR(255)
, @AuditKey INT
, @DisableNotification BIT
, @PackageExecutionLogID INT
, @EnvironmentName NVARCHAR(128) = NULL
, @Use32BitRunTime BIT = FALSE
DECLARE @execution_id BIGINT = 0;
-- Create a package execution
IF @EnvironmentName IS NULL BEGIN
  EXEC [SSISDB].[catalog].[create_execution]
    @execution_id=@execution_id OUTPUT,
  DECLARE @EnvironmentID AS INT
  SELECT @EnvironmentID = [reference_id]
   FROM SSISDB.[internal].[environment_references] WITH(NOLOCK)
   WHERE [environment_name] = @EnvironmentName
    AND [environment_folder_name] = @ProjectFolder
  EXEC [SSISDB].[catalog].[create_execution]
    @execution_id=@execution_id OUTPUT,

Posted On Thursday, November 22, 2012 6:59 AM | Comments (2)

Copyright © Kevin Shyr

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski