DTS Programming: Redistributing DTS DLL’s

http://www.sqldts.com/225.aspx

Advertisements

DTS: execute dts package in SQL Agent

DECLARE @cmd        NVARCHAR(4000)
SET @cmd = N'dtsrun /Smy_server /Nmy_dts_package /E'

---------------------------------------------------------------------
DECLARE @outputs    TABLE 
                        (
                            row_num     INT     IDENTITY(0, 1),
                            output NVARCHAR(MAX)
                        )
DECLARE @rc         INT
DECLARE @err_msg    NVARCHAR(MAX)

INSERT INTO @outputs
    EXEC @rc = xp_cmdshell @cmd

IF @rc != 0
BEGIN
    SET @err_msg = ''
    
    SELECT @err_msg = @err_msg + NCHAR(13) + NCHAR(10) + ISNULL(output, '')
    FROM @outputs
    ORDER BY row_num
    
    RAISERROR (@err_msg, 16, 1)
END