Friday, September 27, 2019

Find stored procedure by SID: SQL SERVER

select Object_Name(2103678542);

SELECT  requests.session_id,
        requests.status,
        requests.command,
        requests.statement_start_offset,
        requests.statement_end_offset,
        requests.total_elapsed_time,
        details.text
FROM    sys.dm_exec_requests requests
CROSS APPLY sys.dm_exec_sql_text (requests.sql_handle) details
WHERE   requests.session_id =194
ORDER BY total_elapsed_time DESC

SELECT  SUBSTRING(detail.text,
                  requests.statement_start_offset / 2,
                  (requests.statement_end_offset - requests.statement_start_offset) / 2)
FROM    sys.dm_exec_requests requests
CROSS APPLY sys.dm_exec_sql_text (requests.sql_handle) detail
WHERE   requests.session_id = 194

No comments:

Post a Comment