Created
June 20, 2019 15:52
-
-
Save weeksdev/b45c9127a9222038ba2857f3b876ca28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
cast(r.total_elapsed_time as decimal(18,2)) / 1000 / 60, | |
r.session_id | |
,st.TEXT AS batch_text | |
,SUBSTRING(st.TEXT, statement_start_offset / 2 + 1, ( | |
( | |
CASE | |
WHEN r.statement_end_offset = - 1 | |
THEN (LEN(CONVERT(NVARCHAR(max), st.TEXT)) * 2) | |
ELSE r.statement_end_offset | |
END | |
) - r.statement_start_offset | |
) / 2 + 1) AS statement_text | |
,qp.query_plan AS 'XML Plan' | |
,r.* | |
FROM sys.dm_exec_requests r | |
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS st | |
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) AS qp | |
ORDER BY cpu_time DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment