SQL Server 2005 查询历史记录 [英] SQL Server 2005 Query History
本文介绍了SQL Server 2005 查询历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下 SQL 轻松查看最近运行的查询列表:
I can easily see a list of recently run queries using the following SQL:
SELECT deqs.last_execution_time AS [Time],
dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC
此查询返回 8,500 行 - 今天针对数据库执行的所有查询.
This query returns 8,500 rows - all queries executed against the DB today.
问题:有什么办法可以查看整周针对数据库运行的查询?特定的一天怎么样?
Question: Is there any way to see the queries run against the DB for the entire week? How about for a specific day?
推荐答案
每次重新启动 SQL Server 时,sys.dm_exec_query_stats
中的数据都会重置.因此,如果您只看到一天的数据,那么服务器肯定在很久以前就已重置.
The data in sys.dm_exec_query_stats
is reset every time SQL Server is restarted. So if you're only seeing a day's worth of data, the server must have been reset about that long ago.
这篇关于SQL Server 2005 查询历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文