美文网首页
sqlserver 查询正在执行的sql

sqlserver 查询正在执行的sql

作者: jianghushao | 来源:发表于2021-08-12 09:18 被阅读0次
SELECT TOP 5 total_worker_time/execution_count AS [Avg CPU 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 statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
ORDER BY total_worker_time/execution_count DESC;

相关文章

网友评论

      本文标题:sqlserver 查询正在执行的sql

      本文链接:https://www.haomeiwen.com/subject/irnkbltx.html