SQLServer数据库监控代码

SQLServer数据库监控代码:

SELECT TOP 500 creation_time, total_worker_time, last_worker_time,
    max_worker_time, min_worker_time,
    SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
    ((CASE statement_end_offset
    WHEN -1 THEN DATALENGTH(st.text)
    ELSE qs.statement_end_offset END
    - qs.statement_start_offset)/2) + 1) as statement_text
    FROM sys.dm_exec_query_stats as qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as st
    ORDER BY 1 DESC

 

posted @ 2016-09-19 15:25  代码沉思者  阅读(992)  评论(0编辑  收藏  举报