SqlServer 查看死锁信息

SELECT 0 ,blocked FROM (SELECT * FROM sys.sysprocesses WHERE blocked>0 ) a WHERE NOT EXISTS(SELECT * FROM (SELECT * FROM sys.sysprocesses WHERE blocked>0 ) b WHERE a.blocked=spid) UNION SELECT spid,blocked FROM sys.sysprocesses WHERE blocked>0 使用查询后的进程ID可以查看死锁元凶的Sql语句和被牺牲Sql语句。 DBCC INPUTBUFFER(82) 附人为制造死锁 BEGIN TRANSACTION SELECT * FROM 表名 WITH (TABLOCKX) WAITFOR DELAY '00:05:00 ' COMMIT TRANSACTION
posted on 2011-03-16 16:36  永无止境  阅读(401)  评论(0编辑  收藏  举报