今天遇见一个挺好的语句,保留下来了。
需要的自取
SELECT TOP 1000 QS.creation_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 语句块, ST.text as 语句, QS.total_worker_time as 总执行时间毫秒, QS.last_worker_time as 上次执行时间毫秒, QS.max_worker_time as 最大执行时间毫秒, QS.min_worker_time as 最小执行时间毫秒 FROM sys.dm_exec_query_stats QS CROSS APPLY sys.dm_exec_sql_text(QS.sql_handle) ST WHERE QS.creation_time BETWEEN convert(varchar(10),getdate(),23) AND convert(varchar(10),getdate()+1,23) ORDER BY QS.total_worker_time DESC