是否可以记录在 SQL Server 上执行的每个查询的文本?
我们经常遇到这种情况,即我们的应用程序每周都会停止响应几次。我想做的是能够查看 SQL Server 上运行的查询文本。
我可以使用 sp_who 来查看打开的连接,但是它不显示实际的查询文本。
如果我可以看到冻结我的数据库的查询,我就可以有一个优化的起点。
这发生在几分钟前,我们的系统管理员不得不重新启动盒子。这种重启是不可持续的。
我应该采取什么步骤?
我想查看我的服务器上运行的查询的实际文本。
SQL Server 2000
We have this recurring situation where several times a week our application stops responding. What I would like to do is be able to view the text of the query running on SQL Server.
I can use sp_who
to see the open connections, but, it does not display the actual query text.
If I can see the query that is freezing my database I can have a starting point for optimization.
This happened a few minutes ago and our sys admin had to reboot the box. This rebooting is not sustainable.
What steps should I take?
I would like to see the actual text of the queries that are running on my server.
SQL Server 2000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在阻止发生时使用此命令:
这将列出所有活动的 SPID、谁正在阻止它们以及每个 SPID 的 SQL
编辑
此查询适用于 SQL Server 2005+,最初的问题没有说明 SQL Server 2000
use this while the block is happening:
this will list all active SPIDs, who is blocking them and the SQL of each SPID
EDIT
this query is for SQL Server 2005+, initial question did not state SQL Server 2000
请参阅文章如何监视 SQL Server 2005 和 SQL Server 2000 中的阻塞,了解 < a href="http://support.microsoft.com/kb/271509" rel="nofollow">
sp_blocker_pss08
(SQL Server 2000 兼容脚本)。See the article How to monitor blocking in SQL Server 2005 and in SQL Server 2000 for the definition of
sp_blocker_pss08
(a SQL Server 2000 compatible script).