Sqlserver 데이터베이스의 잠금 해제를 조회하는 저장 프로세스
?
CREATE procedure sp_who_lock as begin 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 return @@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 return @@error select @ count = count (*),@ index =1 from #temp_who_lock if @@error<>0 return @@error if @ count =0 begin select ' ' return 0 end while @ index <=@ count begin if exists( select 1 from #temp_who_lock a where id>@ index and exists( select 1 from #temp_who_lock where id<=@ index and a.blk=spid)) begin set @lock=1 select @spid=spid,@blk=blk from #temp_who_lock where id=@ index select ' : ' + CAST (@spid AS VARCHAR (10)) + ' , SQL ' select @spid, @blk dbcc inputbuffer(@spid) dbcc inputbuffer(@blk) end set @ index =@ index +1 end if @lock=0 begin set @ index =1 while @ index <=@ count begin select @spid=spid,@blk=blk from #temp_who_lock where id=@ index if @spid=0 select ' :' + cast (@blk as varchar (10))+ ' , SQL ' else select ' SPID:' + CAST (@spid AS VARCHAR (10))+ ' ' + ' SPID:' + CAST (@blk AS VARCHAR (10)) + ' , SQL ' dbcc inputbuffer(@spid) dbcc inputbuffer(@blk) set @ index =@ index +1 end end drop table #temp_who_lock return 0 end GO 질의 분석기에서 다음을 수행합니다.
exec sp_who_lock
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.