如何记录存储过程的频率和最后使用时间? [英] How do I log the frequency and last-used time for a stored procedure?
本文介绍了如何记录存储过程的频率和最后使用时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道一组存储过程的运行频率以及上次使用它们的时间.
I want to know how often a set of stored procedures run, and the last time they were used.
我正在考虑将调用添加到数据库中每个存储过程的顶部,以使用以下模式插入/更新表:
I am thinking of adding calls to the top of every stored procedure in the database to insert/update a table, with the following schema:
SprocName ExecCount LastExec
----------------------------------
GetCompany 434 2009-03-02
ExportDist 2 2008-01-05
显然,将代码添加到每个sproc并不是很有效.
Obviously, adding code to every sproc isn't exactly productive.
SQL Server 2005是否有内置功能可以提供帮助?
Is there a built in feature of SQL Server 2005 that can help?
还是有更好的方法?
推荐答案
There's an MSDN blog here that talks about various options. For SQL 2005, this boils down to:
- 进行服务器端跟踪,请注意,这不是轻量级的选择 要做
- 更改存储过程以包括执行日志记录
- Do a server side tracing, be aware that this is not a light weight option to do
- Change your stored procedures to include the logging of the execution
这篇关于如何记录存储过程的频率和最后使用时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文