Querying the Most Recently Executed SQL Statements in SQL Server

2019年12月18日 110点热度 1人点赞 0条评论
内容目录

Method of use:
Simply create a new query and paste the code inside.
You can simplify the query as needed.

SELECT TOP 1000 
       ST.text AS 'Executed SQL Statement',
       QS.execution_count AS 'Execution Count',
       QS.total_elapsed_time AS 'Elapsed Time',
       QS.total_logical_reads AS 'Logical Reads',
       QS.total_logical_writes AS 'Logical Writes',
       QS.total_physical_reads AS 'Physical Reads',       
       QS.creation_time AS 'Execution Time',  
       QS.*
FROM   sys.dm_exec_query_stats QS
       CROSS APPLY 
sys.dm_exec_sql_text(QS.sql_handle) ST
WHERE  QS.creation_time BETWEEN '2018-12-17 00:00:00' AND '2018-12-19 11:00:00' 
ORDER BY QS.creation_time desc;

痴者工良

高级程序员劝退师

文章评论