使用語句查詢SQL Server執行過的語句及執行效率
SELECT?TOP?1000ST.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.*
FROMsys.dm_exec_query_stats?QS
CROSS?APPLY?
sys.dm_exec_sql_text(QS.sql_handle)?ST
--WHERE?QS.creation_time?BETWEEN?'2015-08-01?00:00:00'?AND?'2015-09-02?11:00:00'?
ORDER?BY
QS.creation_time?DESC