SqlServer 查询锁表/当前进程数

SqlServer查询锁表
--查询出死锁的SPID
select blocked
from (select * from sysprocesses where  blocked>0 ) a 
where not exists(select * from (select * from sysprocesses where  blocked>0 ) b 
where a.blocked=spid)

--输出引起死锁的操作
DBCC INPUTBUFFER (@spid)

--查询当前进程数
select count(-1) from sysprocesses 
where dbid in (select dbid from sysdatabases where name like '%telcount%');

猜你喜欢

转载自475900947.iteye.com/blog/2114211