if exists(select * from tempdb.dbo.sysobjects where id=object_id(N'tempdb.dbo.#temp'))
drop table #temp
/*
SELECT * INTO #temp
FROM OPENROWSET('SQLOLEDB',
'SERVER=.;UID=sa;PWD=1234567;DATABASE=MASTER',
'EXEC SP_LOCK') AS A
*/
/*
create table #temp
(
spid int,
dbid int,
objid int,
indid int,
type varchar(20),
resource varchar(20),
mode varchar(10),
status varchar(20)
)
insert into #temp
exec sp_lock @@spid
*/
select spid,dbname=db_name(dbid),objname=object_name(objid),indexes=(select name from sysindexes where id =objid and indid=t.indid),
type,resource,mode,status from #temp t
drop table #temp
/*
SELECT * INTO #temp
FROM OPENROWSET('SQLOLEDB',
'SERVER=.;UID=sa;PWD=1234567;DATABASE=MASTER',
'EXEC SP_LOCK') AS A
*/
/*
create table #temp
(
spid int,
dbid int,
objid int,
indid int,
type varchar(20),
resource varchar(20),
mode varchar(10),
status varchar(20)
)
insert into #temp
exec sp_lock @@spid
*/
select spid,dbname=db_name(dbid),objname=object_name(objid),indexes=(select name from sysindexes where id =objid and indid=t.indid),
type,resource,mode,status from #temp t
浙公网安备 33010602011771号