将跟踪信息连接到被阻止的用户 [英] Connecting Trace info to blocked users?

查看:55
本文介绍了将跟踪信息连接到被阻止的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在master.dbo.sysprocesses中我可以过滤被阻止的用户(被阻止> 0)

我可以创建一个自连接(ON SPID =已阻止)以查看用户是什么

Loginame导致阻止。在[cmd]列中,我可以看到

命令正在运行导致该块的违规阻止程序,但

它只是说SELECT没有关于存储过程的详细信息

导致阻塞。


如果我正在运行Trace,我可以看到确切的存储过程

包括每个cmd运行的参数。


有没有办法在查找时查看相同的跟踪信息

被阻止用户在master.dbo.sysprocesses或其他地方?


理想情况下我想要的是一个被阻止的用户列表,他们导致了

块以及导致

块的存储过程名称(或其他恶作剧)。


感谢任何帮助。

lq

解决方案

你可以这样做,运行sp_who2

有一个名为BlkBy的字段抓住id

运行DBCC INPUTBUFFER(ID)以获取SQL语句

http://sqlservercode.blogspot.com/


有没有办法让EXEC(''DBCC INPUTBUFFER(BlkBy)WITH / b
NO_INFOMSGS''))成为SELECT语句中的一列?


CREATE TABLE #SystemUsers(id int identity,SPID int,BlockerLoginame

nvarchar(255),BlockingSQL nvarchar(2000))

INSERT INTO #SystemUsers(SPID ,BlockerLoginame,BlockingSQL)

SELECT

SPID,

loginame,

/ *(EXEC(''DBCC) INPUTBUFFER(BlkBy)与NO_INFOMSGS''))作为BlockingSQL

??????? * /

来自master.dbo.sysprocesses


SELECT

s.spid,

status ,

登录名,

主机名,

cmd,

cpu,

last_batch ,

login_time,

封锁,

x.BlockerLoginame,

waittype,

等待时间,

lastwaittype,

waitresource,

dbid,

id,

memusage,

ecid,

open_tran,

sid,

hostprocess,

nt_domain,

nt_username,

net_address,

net_library,

context_info

来自master.dbo.sysprocesses s

LEFT OUTER JOIN #SystemUsers x ON x.SPID = s.Blocked

WHERE Blocked> ; 0


将sp_who2的结果插入表中

删除BlkBy为空的所有内容

循环通过此表并将DBCC输入缓冲区结果插入

anothe r table

用sysprocesses加入最后一个表

http://sqlservercode.blogspot.com/


In master.dbo.sysprocesses I can filter for blocked users (Blocked >0)
and I can create a self join(ON SPID = Blocked) to see what user
Loginame is causing the block. In the column [cmd] I can see the
command that the offending blocker is running to cause the block, but
it only says "SELECT" etc. with no details about the stored procedure
that is causing the block.

If I am running a Trace, I can see the exact stored procedures
including the parameters that every cmd is running.

Is there a way to see that same Trace information when looking for
blocked users in master.dbo.sysprocesses, or in some other place?

Ideally what I want is a list of blocked users, who is causing the
blocks and the stored procedure name (or other mischief) causing the
block.

Any help is appreciated.
lq

解决方案

You can do this, run sp_who2
there is a field named BlkBy grab the id
run DBCC INPUTBUFFER (ID) to get the SQL statement

http://sqlservercode.blogspot.com/


Is there a way to get the EXEC (''DBCC INPUTBUFFER (BlkBy) WITH
NO_INFOMSGS'')) to become a column in the resulting SELECT statement?

CREATE TABLE #SystemUsers (id int identity, SPID int, BlockerLoginame
nvarchar(255), BlockingSQL nvarchar(2000))
INSERT INTO #SystemUsers (SPID, BlockerLoginame, BlockingSQL)
SELECT
SPID,
loginame,
/* (EXEC (''DBCC INPUTBUFFER (BlkBy) WITH NO_INFOMSGS'')) As BlockingSQL
??????? */
FROM master.dbo.sysprocesses

SELECT
s.spid,
status,
loginame,
hostname,
cmd,
cpu,
last_batch,
login_time,
kpid,
blocked,
x.BlockerLoginame,
waittype,
waittime,
lastwaittype,
waitresource,
dbid,
uid,
memusage,
ecid,
open_tran,
sid,
hostprocess,
nt_domain,
nt_username,
net_address,
net_library,
context_info
FROM master.dbo.sysprocesses s
LEFT OUTER JOIN #SystemUsers x ON x.SPID = s.Blocked
WHERE Blocked >0


Insert the result of sp_who2 into a table
Delete everything where BlkBy is empty
Loop thru this table and insert the DBCC inputbuffer result into
another table
Join this last table with sysprocesses

http://sqlservercode.blogspot.com/


这篇关于将跟踪信息连接到被阻止的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆