SQL 2005 잠 금 저장 프로시저 보기 spwho_lock
1940 단어 자물쇠sp who lock
호출 방법:해당 데이터 베 이 스 를 선택 하고 exec sp 를 실행 합 니 다.who_lock
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[sp_who_lock]
as
begin
declare @spid int, @bl int, @intTransactionCountOnEntry int, @intRowcount int, @intCountProperties int, @intCounter int
create table #tmp_lock_who (
id int identity(1,1),
spid smallint,
bl smallint
)
IF @@ERROR<>0 RETURN @@ERROR
insert into #tmp_lock_who(spid,bl) select 0 ,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)
union select spid,blocked from sysprocesses where blocked>0
IF @@ERROR<>0 RETURN @@ERROR
--
select @intCountProperties = Count(*),@intCounter = 1
from #tmp_lock_who
IF @@ERROR<>0 RETURN @@ERROR
if @intCountProperties=0
select ' ' as message
--
while @intCounter <= @intCountProperties
begin
--
select @spid = spid,@bl = bl
from #tmp_lock_who where Id = @intCounter
begin
if @spid =0
select ' : '+ CAST(@bl AS VARCHAR(10)) + ' , SQL '
else
select ' SPID:'+ CAST(@spid AS VARCHAR(10))+ ' ' + ' SPID:'+ CAST(@bl AS VARCHAR(10)) +' , SQL '
DBCC INPUTBUFFER (@bl )
end
--
set @intCounter = @intCounter + 1
end
drop table #tmp_lock_who
return 0
end
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
java 다중 스레드 - 자물쇠 상세 및 예시 코드이것은'자전 자물쇠'라고도 합니다.isLocked가true일 때, lock () 를 호출하는 라인은wait () 호출에서 대기를 막습니다.이 스레드가 notify () 호출을 받지 못하거나wait () 에서 되돌아오...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.