Wednesday, July 13, 2011

DTSX execution via stored procedure

CREATE PROCEDURE [dbo].[UspEComm_StockExecutingDTSXPackage]
@IntProcessCount Int,
@dtsFileName VARCHAR(1000),
@ErrorMessage VARCHAR(250) OUTPUT
AS
BEGIN
DECLARE @decrptPassword VARCHAR(200),
@ssisstr VARCHAR(1000), @errCode INT
IF @IntProcessCount = 1
BEGIN
TRUNCATE TABLE ABEInventoryTemp
END
SET @decrptPassword = '"@r@bm0r3"'
SET @ssisstr = 'DTExec.exe /FILE "' + @dtsFileName + '" /DECRYPT ' + @decrptPassword + ' /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING EW '
EXEC @errCode = xp_cmdshell @ssisstr
IF @errCode=0
BEGIN
SET @ErrorMessage='The package executed successfully.'
END
ELSE IF @errCode=1
BEGIN
SET @ErrorMessage='The package failed.'
END
ELSE IF @errCode=3
BEGIN
SET @ErrorMessage='The package was canceled by the user.'
END
ELSE IF @errCode=4
BEGIN
SET @ErrorMessage='The utility was unable to locate the requested package. The package could not be found.'
END
ELSE IF @errCode=5
BEGIN
SET @ErrorMessage='The utility was unable to load the requested package. The package could not be loaded.'
END
ELSE IF @errCode=6
BEGIN
SET @ErrorMessage='The utility encountered an internal error of syntactic or semantic errors in the command line.'
END
ELSE
BEGIN
SET @ErrorMessage='The package failed.'
END
END
/*
SYMITAR..ACCOUNT
select top 5 * from FTPDownloadReport order by idpk desc
truncate table inventorytemp
select count(*) from inventorytemp
Declare @ErrorMessage varchar(100)
EXEC UspEComm_ExecutingDTSXPackage 'D:\NewBooks\SQL Packages\I2FULLINVPackage.dtsx',@ErrorMessage
Print @ErrorMessage
*/
SET QUOTED_IDENTIFIER OFF

No comments:

Post a Comment