Thomas LeBlanc

How to execute a Deployed Package from the SSIS Catalog with various options

March 21, 2017 by

In my previous two articles on SQL Server integration Services (SSIS), Parameterizing Database Connection in SSIS and Deploying Packages to SSIS Catalog (SSISDB), packages were developed, deployed and configured in the SSIS Catalog. Now, it is time to execute the packages with various options. There are a couple of ways to do this, but we need to be able to change the parameter values as well as monitor for failures or successes.

The most intuitive execution for a DBA would be to script the T-SQL to execute the package. When we do this, the package is run asynchronous, so it starts and returns quickly to the method used to execute. The T-SQL script uses a status to indicate if the package is executing, has succeeded or has failed along with various other values along the same line.

We can get this script by trying to execute a package deployed to the SSIS Catalog. If you right-click on the package from the SSIS Catalog, there will be a submenu called Execute… like Figure 1.


Figure 1: Executing a Package from SSIS Catalog

The Execute Package screen appears where you can change Project Parameter values. The values are retrieved based on the deployed values, assigned environment or the configured values after the project is deployed. Configuration of the changed values can come from one or more Environments that are assigned to the package within the deployed project.


Figure 2: Executing a Package from SSIS Catalog

There is a Script button at the top of the execute screen where the text can be saved to a file, the clipboard or displayed in a new query window. Figure 3 shows the script in a new query window after some formatting changes.


Figure 3: Script for Executing a Deployed Package

The script starts with a declaration of the variable @execution_ID. This is the variable that will hold the status of the executing package while it is running asynchronous. Since no Project Parameters were changed, there is nothing declared or set for this script. The execution will use the SSIS Catalog configured values.

If the above script is executed, it will complete with no errors. The problem is only the SSIS Catalog logging will have the execution status for the running package. Nothing is returned to the execution of the script from the SSIS package. The value can be obtained by creating a loop to check the declared @execution_ID variable.

The possible values are:

  1. running
  2. created
  3. canceled
  4. failed
  5. pending
  6. ended unexpectedly
  7. succeeded
  8. stopping
  9. completed

The loop would need to check the value of @execution_ID and if it is 1, 2, 5 or 8, it is still running. Anything else would be completed. We would need to report a problem if the value ended up as 3, 4 or 6. Figure 4 shows the additional logic for looping to check the completion of the execution

Figure 4 Execution a While Loop

These packages were developed in a separate environment than production. So, when we deploy to a production server, the parameter values will be the same as development (or QA). The Environment of the SSIS Catalog is helpful with changing these deployed values. It is also helpful because the Project Parameters are used by multiple Packages in a Project. That is why the switch to Project Parameters is so important along with containing packages in a project deployed to the SSIS Catalog.

Once deployed to the production server, we can create an Environment for the Project. Figure 5 shows where this is done.


Figure 5 QA Environment

First, the Environment has to be created with a name and description. Once that is done, the properties of the Environment can be edited. Figure 6 shows an Environment for changing the staging and production database names as well as the instance name.


Figure 6 Setting Up An Environment

Once this is save, we can relate an Environment to a Project. The Environment has to be created in the project’s Environment folder. The Project can be assigned values from the Environment variables to specific Project Parameters like Figure 7.


Figure 7 Assigning Environment Variable to Project Parameter

This enables having the same deployed package run with different values for production versus QA. It also means the project and its packages only have to be deployed to production, if the developer feels ok with that. It does not prevent you from deploying to development, QA and/or production.

You can also setup SQL Server Agent jobs to run with different Environments. Figure 8 shows an agent job with an Environment assigned. The variable names created in the Environment must match the Project Parameter names for this to work in the SQL Server Agent job.


Figure 8 Environment Assigned To Package SQL Server Agent

The step of a SQL Server Agent job can have a text file log the information about a success or failure. If you go to the Advanced option in the top left of the Job Step properties, there is an Output file text box and ellipse where you can find a path and enter a filename. Figure 9 shows an option to write the output of the step to a specific location. There is also an option to ‘Append step output to existing file’. If not checked, the file is overwritten when the step is run. Not checking this box appends the output to the same file keeping the history of executions. If you use the append option, the file will grow larger with each run, so be sure to check the size and purge frequently.


Figure 9 Job Step Properties

Even though we started with scripting T-SQL to launch a package, we saw that assigning the Project an Environment will override the deployed values for Project Parameter(s). The Environment can also be related to an SSIS package as a step in the SQL Server Agent. The Step has a way to log information related to execution and errors.

Side Note

The asynchronous execution can be changed to run synchronous. The syntax below accomplishes making the package run synchronous from a T-SQL script.

The parameter value change would make the execution of this package through T-SQL wait to return to caller once the execution finishes. This includes if it fails.

See more

For SSIS package documentation, consider ApexSQL Doc, a tool that enables documenting SSIS packages from file system, SSIS package store, SQL Server, SSISDB catalog and SSIS project file in different output formats, and with various included details.

To compare SSIS packages with each other, consider ApexSQL Diff.

Reference links:


Thomas LeBlanc

Thomas LeBlanc

Thomas LeBlanc is a Data Warehouse Architect in Baton Rouge, LA. Today, he works with designing Dimensional Models in the financial area while using Integration (SSIS) and Analysis Services (SSAS) for development and SSRS & Power BI for reporting.

Starting as a developer in COBOL while at LSU, he has been a developer, tester, project manager, team lead as well as a software trainer writing documentation. Involvement in the SQL Server community includes speaking at SQLPASS.org Summits and SQLSaturday since 2011 and has been a speaker at IT/Dev Connections and Live! 360.

Currently, he is the Chair of the PASS Excel Business Intelligence Virtual Chapter and worked on the Nomination Committee for PASS Board of Directors for 2016.

View all posts by Thomas LeBlanc
Thomas LeBlanc
SSIS packages

About Thomas LeBlanc

Thomas LeBlanc is a Data Warehouse Architect in Baton Rouge, LA. Today, he works with designing Dimensional Models in the financial area while using Integration (SSIS) and Analysis Services (SSAS) for development and SSRS & Power BI for reporting. Starting as a developer in COBOL while at LSU, he has been a developer, tester, project manager, team lead as well as a software trainer writing documentation. Involvement in the SQL Server community includes speaking at SQLPASS.org Summits and SQLSaturday since 2011 and has been a speaker at IT/Dev Connections and Live! 360. Currently, he is the Chair of the PASS Excel Business Intelligence Virtual Chapter and worked on the Nomination Committee for PASS Board of Directors for 2016. View all posts by Thomas LeBlanc

2,919 Views