SQL Server 查询最新执行过个SQL语句

内容纲要

使用方法:
直接新建查询,将代码粘贴到里面即可。
可以根据需求简化查询

SELECT TOP 1000 
       ST.text AS '执行的SQL语句',
       QS.execution_count AS '执行次数',
       QS.total_elapsed_time AS '耗时',
       QS.total_logical_reads AS '逻辑读取次数',
       QS.total_logical_writes AS '逻辑写入次数',
       QS.total_physical_reads AS '物理读取次数',       
       QS.creation_time AS '执行时间' ,  
       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;
点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注