日期:2014-05-16 浏览次数:20590 次
--1.查看阻塞信息
select spid,loginame,waitresource from master..sysprocesses
where blocked <> 0
/*
spid loginame waitresource
53 ggg-PC\Administrator RID:1:1:1385:0
*/
--2.查看语句
dbcc inputbuffer(53)
/*
eventInfo
select * from xx
*/
--3.查看锁的信息
exec sp_lock @spid1 = 53
/*
spid dbid ObjId IndId Type Resource Mode Status
53 1 1335727861 0 PAG 1:1385 IS GRANT
53 1 1335727861 0 RID 1:1385:0 S WAIT
53 1 1335727861 0 TAB IS GRANT
*/
--select OBJECT_ID(1335727861) as table_name
--4.打开数据库
select *
from sysdatabases
where dbid = 1
/*
name dbid sid mode status status2 crdate reserved category cmptlevel filename version
master 1 0x01 0 65544 1090520064 2003-04-08 09:13:36.390 1900-01-01 00:00:00.000 0 100 C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\master.mdf 661
*/
--5.根据锁信息中的ObjId列:1335727861,找到了这个xx表
select *
from sysobjects
where id = 1335727861
/*
name id xtype uid info status base_schema_ver replinfo parent_obj crdate ftcatid schema_ver stats_schema_ver type userstat sysstat indexdel refdate version deltrig instrig updtrig seltrig category cache
xx 1335727861 U 1 0 0 0 0 0 2013-12-25 08:55:07.523 0 0 0 U 1 3 0 2013-12-25 08:55:07.523 0 0 0 0 0 0 0
*/