--建立SP_LOCK输出缓存表
if exists( select * from tempdb..sysobjects where name like '#temp%' and type ='u')
begin
drop table #temp
create table #temp(spid int,dbid int ,objid int,indid int,type varchar(3),resource varchar(20)
,mode varchar(20),status varchar(5))
end
begin tran
update WBK_PDE_head set [COP_EMS_NO]='abcde' where wbook_no='BE404942850177'
insert #temp exec sp_lock @@spid
commit tran
-----获取dbid
--select DB_ID('Test')
--只查看定制的数据库的相关资源,sql 2008
select spid,数据库=DB_NAME(dbid),对象=OBJECT_NAME(objid),
索引=(select name from sysindexes where ID=OBJID and indid=t.indid ),
TYPE,resource,mode,status from #temp t where dbid=28
order by dbid,objid,indid
---
---以SQL 2005的sys.indexes表查询相关数据
select spid,数据库=DB_NAME(dbid),对象=OBJECT_NAME(objid),
索引=(select name from sys.indexes where object_id=OBJID and index_id=t.indid ),
TYPE,resource,mode,status from #temp t where dbid=28
order by dbid,objid,indid