MSSQL 死锁和阻塞 查看事务
程序员文章站
2022-06-02 12:25:59
...
declare @spid int
declare @blk int
declare @count int
declare @index int
declare @lock tinyint
set @lock=0
create table #temp_who_lock
(
id int identity(1,1),
spid int,
blk int
)
if @@error<>0 select @@error
insert into #temp_who_lock(spid,blk)
select 0 ,blocked
from (select * from master..sysprocesses where blocked>0)a
where not exists(select * from master..sysprocesses where a.blocked =spid and blocked>0)
union select spid,blocked from master..sysprocesses where blocked>0
if @@error<>0 select @@error
select @count=count(*),@index=1 from #temp_who_lock
if @@error<>0 select @@error
if @count=0
begin
select '没有阻塞和死锁信息'
end
上一篇: 价值链重塑:大数据洞察与精准营销
下一篇: 青萝卜的做法大全是什么