SELECT DEQS.last_execution_time AS [Time]
, DEST.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS DEQS
CROSS APPLY sys.dm_exec_sql_text(DEQS.sql_handle) AS DEST
ORDER BY DEQS.last_execution_time DESC
you will the below output screen :
If you like to see execution plan as well then write the blow command:
SELECT DEQS.last_execution_time AS [Time]
,DEST.TEXT AS [Query]
,DECP.QUERY_PLAN
FROM sys.dm_exec_query_stats AS DEQS
CROSS APPLY sys.dm_exec_sql_text(DEQS.sql_handle) AS DEST
CROSS APPLY sys.dm_exec_query_plan(DEQS.plan_handle) AS DECP
ORDER BY DEQS.last_execution_time DESC
In the last column of above output is the XML formatted Execution Plan of the query.
No comments:
Post a Comment