简体   繁体   English

是否可以确定给定的SQL Server进程正在运行什么查询?

[英]Is it possible to tell what query a given SQL Server process is running?

Our application has started having problems with SQL Server 2005 queries getting blocked. 我们的应用程序开始出现SQL Server 2005查询被阻止的问题。 Is is possible to tell what query the blocking process is running? 是否可以判断阻塞进程正在运行哪个查询? If it is possible how is it done? 如果有可能怎么做?

If you are running an SQL Server version bigger than Express, the Activity Monitor of SQL Server Management Studio allows you to make a snapshot of the current activity on the system. 如果您运行的SQL Server版本大于Express,则可以使用SQL Server Management Studio的“ 活动监视器”为系统上的当前活动制作快照。 There, you can see which connection is blocking which other connection. 在那里,您可以看到哪个连接正在阻止哪个其他连接。 You can also see which tables (or other objects) are locked by these connections, giving you a hint on what causes the blocking. 您还可以查看哪些表(或其他对象)已被这些连接锁定,从而提示您导致阻塞的原因。

If you know the SPID of the blocking process, you can run DBCC INPUTBUFFER(xxx) , where xxx is the SPID. 如果知道阻止进程的SPID,则可以运行DBCC INPUTBUFFER(xxx) ,其中xxx是SPID。 If you're using Activity Monitor, you can achieve the same thing by double-clicking the row containing that process. 如果您使用的是活动监视器,则可以通过双击包含该进程的行来实现相同的目的。

I know that it is possible, however, not being a sql guru I can't give you a query to run that will tell you what query is blocking. 我知道有可能,但是,如果不是sql专家,我无法给您提供要运行的查询,该查询将告诉您哪些查询正在阻止。 I will plug an application that I am evaluating which is doing very well for us so far. 我将插入一个我正在评估的应用程序,该应用程序到目前为止对我们来说非常好。

Sql Sentry has been helping my small team identify problems areas. Sql Sentry一直在帮助我的小型团队确定问题区域。 This is noteworthy in that we only have one person who has any proficiency with sql server. 值得注意的是,我们只有一个精通sql server的人员。

I have no affiliation with the company nor am I being compensated for the plug in any way . 我与该公司没有任何隶属关系,也没有以任何方式获得插头的补偿。

Run a SQL Profiler trace, only including Blocked Process Report (within Errors). 运行SQL事件探查器跟踪,仅包括阻止的进程报告(错误内)。 Keep it running during the day and monitor it for blocking information. 使其保持白天运行并监视其是否有阻塞信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM