Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2016 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6fc90ef62a7ef6484415ff914388f5be to your computer and use it in GitHub Desktop.
Save anonymous/6fc90ef62a7ef6484415ff914388f5be to your computer and use it in GitHub Desktop.
-- Create the execution object
DECLARE @execution_id BIGINT
EXEC [SSISDB].[catalog].[create_execution]
@package_name = N'Package2.dtsx'
, @project_name = N'Project1'
, @folder_name = N'Folder1'
, @use32bitruntime = False
, @reference_id = NULL
, @execution_id = @execution_id OUTPUT
-- System parameters
EXEC [SSISDB].[catalog].[set_execution_parameter_value]
@execution_id
, @object_type = 50 -- System parameter
, @parameter_name = N'SYNCHRONIZED'
, @parameter_value = 1
-- Execute the package
EXEC [SSISDB].[catalog].[start_execution] @execution_id
-- Check package status, and fail script if the package failed
IF 7 <> (SELECT [status] FROM [SSISDB].[catalog].[executions] WHERE execution_id = @execution_id)
RAISERROR('The package failed. Check the SSIS catalog logs for more information', 16, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment