declare @dbname nvarchar(200),@objid nvarchar(200)
set @dbname='PETTY_CASH_ORIGIN'
set @objid='PC_INVOICE_MASTER'
Select a.req_spid,db_name(a.rsc_dbid) as 數據庫,object_name(a.rsc_objid) as 表,
資源類型=case a.rsc_type when 1 then 'NULL 資源(未使用)'
when 2 then '數據庫'
when 3 then '文件'
when 4 then '索引'
when 5 then '表'
when 6 then '頁'
when 7 then '鍵'
when 8 then '擴展盤區'
when 9 then 'RID(行 ID)'
when 10 then '應用程序'
end,
鎖模式=case a.req_mode when 0 then 'Null'
when 1 then 'Sch-S(架构性定性)'
when 2 then 'Sch-M(架构修改)'
when 3 then 'S(共享鎖)'
when 4 then 'U更新'
when 5 then 'X排它鎖'
when 6 then 'IS意向共享'
when 7 then ''
end,
鎖狀態=case a.req_status when 1 then '已授權'
when 2 then '正在轉換'
when 3 then '正在等待'
end,
對象類型=case a.req_ownertype when 1 then '事務'
when 2 then '遊標'
when 3 then '會話'
end
from master.dbo.syslockinfo as a,master.dbo.sysprocesses as b
where a.rsc_dbid = b.dbid AND a.req_spid = b.spid
AND a.rsc_type=5 and object_name(a.rsc_objid)=@objid and db_name(a.rsc_dbid)=@dbname
order by req_spid