码迷,mamicode.com
首页 > 数据库 > 详细

mmsql查看最近操作日志

时间:2016-11-17 13:29:13      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:cal   ota   stat   app   from   avg   sql   gic   sub   

SELECT TOP 2000 query_stats.query_hash AS "Query Hash",
Sum(Query_Stats.total_logical_Reads) as Total_Logical_Reads,
Sum(Query_Stats.total_physical_Reads) as Total_physical_Reads,
SUM(query_stats.total_worker_time) / SUM(query_stats.execution_count) AS "Avg CPU Time",
SUM(query_stats.execution_count) as CNT, SUM(query_stats.total_worker_time) as "Total CPU Time",
MIN(query_stats.statement_text) AS "Statement Text"
FROM
(SELECT QS.*,
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) as query_stats
GROUP BY query_stats.query_hash
ORDER BY 5 DESC;

mmsql查看最近操作日志

标签:cal   ota   stat   app   from   avg   sql   gic   sub   

原文地址:http://www.cnblogs.com/zhian/p/6073275.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!