Created
April 10, 2024 09:55
-
-
Save Apurer/55f4e55eccfa206dc1c1755e8d5d3f59 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 | |
TOP 10 | |
qs.last_execution_time, | |
SUBSTRING(st.text, (qs.statement_start_offset/2) + 1, | |
((CASE qs.statement_end_offset | |
WHEN -1 THEN DATALENGTH(st.text) | |
ELSE qs.statement_end_offset | |
END - qs.statement_start_offset)/2) + 1) AS query_text | |
FROM sys.dm_exec_query_stats qs | |
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st | |
ORDER BY qs.last_execution_time DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment