Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Unable to get return code executing the SSIS package from Stored Procedure

$
0
0

We are executing a SSIS package using a xp_cmdshell command in a SP as shown below. This package does consumes time to execute almost 90 minutes and does get executed successfully too. But the strange thing is we don't get the result in @result variable just because somehow the next sql statement after the below highlighted statement doesn't get executed at all.  After checking execution stats for the SP using the query attached below we observed that somehow the SP vanishes out of the execution stats for the server. Could someone help me in this. 

 SELECT @cmd = 'dtexec /FILE "D:\Program Files\Microsoft SQL Server\100\DTS\Packages\.....\PopulateReport.dtsx"'          

  SELECT @cmd = @cmd + ' /Decrypt T@!0er '          
  SELECT @cmd = @cmd + ' /set \package.variables[vAppID].Value;' + CONVERT(VARCHAR(10),@appId)          
  SELECT @cmd = @cmd + ' /set \package.variables[vDBName].Value;' + '"' + @db + '"'          
  SELECT @cmd = @cmd + ' /set \package.variables[vBuildMFF].Value;' + CONVERT(VARCHAR(10),@BuildMFF)          
  SELECT @cmd = @cmd + ' /set \package.variables[vDFID].Value;' + CONVERT(VARCHAR(10),@DFID)          
  SELECT @cmd = @cmd + ' /set \package.variables[vPushMRFOnly].Value;' + CONVERT(VARCHAR(10),@PushMRFOnly)          
  SELECT @cmd = @cmd + ' /set \package.variables[vExportTableauMRF].Value;' + CONVERT(VARCHAR(10),@ExportTableauMRF)EXEC @result=master..xp_cmdshell @cmd,no_output   

SELECT
    SPID                = er.session_id
    ,Status             = ses.status
    ,[Login]            = ses.login_name
    ,Host               = ses.host_name
    ,BlkBy              = er.blocking_session_id
    ,DBName             = DB_Name(er.database_id)
    ,CommandType        = er.command
    ,SQLStatement       =
        SUBSTRING
        (
            qt.text,
            er.statement_start_offset/2,
            (CASE WHEN er.statement_end_offset = -1
                THEN LEN(CONVERT(nvarchar(MAX), qt.text)) * 2
                ELSE er.statement_end_offset
                END - er.statement_start_offset)/2
        )
    ,ObjectName         = OBJECT_SCHEMA_NAME(qt.objectid,dbid) + '.' + OBJECT_NAME(qt.objectid, qt.dbid)
    ,ElapsedMS          = er.total_elapsed_time
    ,CPUTime            = er.cpu_time
    ,IOReads            = er.logical_reads + er.reads
    ,IOWrites           = er.writes
    ,LastWaitType       = er.last_wait_type
    ,StartTime          = er.start_time
    ,Protocol           = con.net_transport
    ,transaction_isolation =
        CASE ses.transaction_isolation_level
            WHEN 0 THEN 'Unspecified'
            WHEN 1 THEN 'Read Uncommitted'
            WHEN 2 THEN 'Read Committed'
            WHEN 3 THEN 'Repeatable'
            WHEN 4 THEN 'Serializable'
            WHEN 5 THEN 'Snapshot'
        END
    ,ConnectionWrites   = con.num_writes
    ,ConnectionReads    = con.num_reads
    ,ClientAddress      = con.client_net_address
    ,Authentication     = con.auth_scheme
FROM sys.dm_exec_requests er
LEFT JOIN sys.dm_exec_sessions ses
ON ses.session_id = er.session_id
LEFT JOIN sys.dm_exec_connections con
ON con.session_id = ses.session_id
CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) as qt
--WHERE er.session_id = @SessionID
WHERE er.session_id > 50
ORDER BY
    er.blocking_session_id DESC
    ,er.session_id

 


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>