MS SQL Server 2008 如何知道表/存储过程是否正在使用?
有什么方法可以确定任何项目是否正在使用任何表? 当然,问题是表何时是只读的;否则,我可以看到 新插入的行。同样的问题也适用于存储过程。 SQL Server Profiler 可能会对 SP 有帮助,但不确定表。 但我不想坐下来观察 SQL Server Profiler。我希望得到一种通知。 所以基本上,我想设置一个触发器或其他东西,如果表被命中,则读取 它通知我。
感谢您的帮助
Is there any way to determine if any table is in use or not by any project?
Of course question would be when table is only read-only; otherwise, I could see from
new inserted rows. Same question is for a stored procedure. SQL Server Profiler should probably help for SP, not sure about table.
But I don't want to sit and observe SQL Server Profiler. I wish to have a kind of notification.
So basically, I would like to set up a trigger or something, if table gets hit, read then
it notifies me.
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有某种形式的提前规划,我相信答案是“不,你无法 100% 准确地确定使用情况”。
关键是,SQL Server 根本无法知道此类操作和可能会发生活动。您应该能够挑选出 90%、98% 或 99.9% 的所有数据库活动,但如果您需要 100% 保证表 dbo.LegacyDump 是完全不相关的垃圾,而无需参与原始设计和实施(以及完全回忆)你无法达到 100%。
当你到达这一点时,最好的选择是提出风险评估(如果我们删除该表,情况会多么糟糕),一个应急计划(如果结果证明我们不应该删除该表该怎么办)和文档(这样您或任何人都可以清楚地回忆起当发现您杀死了计算 C 级年度奖金的系统时所做的决定。)
Without some form of planning ahead, I believe the answer is "No, you can't determine usage with 100% accurarcy".
The point is, SQL Server simply cannot know that such actions and activities might occur. You should be able to pick out 90%, 98%, or maybe 99.9% of all database activities, but if you need that 100% assurance that table dbo.LegacyDump is flat-out irrelevant junk, without having been in on the original design and implementation (and having total recall) you just can't get to 100%.
When you get to that point, your best bet is to come up with a risk assessment (how bad might it be if we drop the table), a contingency plan (what to do if it turned out we should not have dropped that table), and documentation (so you or whoever can clearly recall the decisions made when it is found out you killed the system that calculates the C-level annual bonuses.)
尝试使用存储过程 sp_who2
链接:http://sqlserverplanet.com/dba/using-sp_who2/
Try using the stored procedure sp_who2
Link : http://sqlserverplanet.com/dba/using-sp_who2/