Showing posts with label SSIS. Show all posts
Showing posts with label SSIS. Show all posts

Tuesday, 27 August 2019

Executing SSIS Packages in SSIS Catalog


We can execute SSIS packages deployed in SSIS Catalog using stored procedure based approach as given below:


DECLARE @execution_id INT

EXEC [SSISDB].[catalog].[create_execution]
@package_name = N'Package.dtsx',
@execution_id = @execution_id OUTPUT,
@folder_name = N'FolderName',
@project_name = N'ProjectName',
@use32bitruntime = False;

EXEC [SSISDB].[catalog].[set_execution_parameter_value]
@execution_id,
@object_type = 30,
@parameter_name = N'FolderName',
@parameter_value = N'ParameterValue';

EXEC [SSISDB].[catalog].[set_execution_parameter_value]
@execution_id,
@object_type = 30,
@parameter_name = N'EnvironmentPath',
@parameter_value = N'EnvironmentValue';

exec catalog.set_execution_parameter_value  @execution_id, 50, 'DUMP_ON_ERROR',1

exec catalog.set_execution_parameter_value  @execution_id, 50, 'LOGGING_LEVEL',3

EXEC [SSISDB].[catalog].[start_execution] @execution_id;

Once we execute the package, we can check the status of execution using the below approach:

DECLARE @status AS BIGINT = 1;

WHILE(@status = 1 OR @status = 2 OR @status = 5 OR @status= 8)
BEGIN
PRINT @status
PRINT 'waiting 5 seconds for Package to finish'
WAITFOR DELAY '00:00:5';

SET @status = (SELECT [Status] FROM SSISDB.[catalog].[executions]
        WHERE execution_id = @execution_id);
END

If we want to execute the SSIS package using commandline, we can take the below approach:

dtexec.exe /isserver "\SSISDB\FolderName\ProjectName\Package.dtsx" /server "ServerName" /parameter $Package::FolderName;"ParameterValue" /parameter $Package::Sleep(Int32);60 /parameter $Package::MaxRun(Int32);300 /parameter $Package::EnvironmentPath;"EnvironmentValue"

Wednesday, 4 February 2009

Problems with unicode csv file generated by SSIS

I had the task of generating a CSV file from SSIS. With all the source columns being in nvarchar datatype, I decided to go for unicode csv file. Everything worked fine, except that all the columns in CSV file, when opened in EXCEL 2007 came under a single column. I tried many options like setting Text qualifier as "(double quotes) or '(single quote) and also dropped and recreated flat file destination. But, no change was observed.

When I myself created a csv file in unicode format in Notepad, it was opened fine by Excel 2007 without issues. Finally, after lot of googling, I found out this is due to 0xFF character inserted in the beginning of file in the forum
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=109794

I had no other choice, but to use Data Conversion transform to convert all the nvarchar, ntext stream into char,text stream before inserting into ANSI flat file destination. Now, it worked without issues. Excel 2007 and SSIS being from Microsoft, and known fact that csv files are usually opened by Excel 2007 and I hoped that unicode csv file from SSIS 2005 would open fine in Excel 2007 and this problem was rather surprise to me.

Hope this problem is resolved in SQL 2008 as simplistic csv files are popular just for the reason that they are easily opened by Excel.

/Venkat

How to Handle SSIS Database movement from one environment to another

Below are the steps to follow the movement of SSISDB from one environment to another: -- opening the existing Database master key in S...