본 게시물은 개인적인 의견으로 작성되었으니 절대적인 정보가 아닐 수 있습니다. 참고만 하시고 궁금한 사항이 있으시면 연락주세요.

티스토리 뷰

SQL Server - CATEGORY

SQL Server KILL command

AWS-in 2015. 11. 11. 08:44

SQL Server에 접속하면 세션이 부여되고 해당 세션안에서 쿼리들이 수행을 하게 된다.

해당 세션을 종료하고 싶을땐 KILL SPID 명령어를 사용하면 된다.

보통 블로킹(Blocking)이 발생할때 헤더블러커 세션을 종료할때 마니 사용된다.


KILL 54
KILL 54 WITH STATUSONLY -- 단지 진행률을 볼뿐 실제 KILL 수행은 안한다.
KILL 'D5499C66-E398-45CA-BF7E-DC9C194B48CF'

UOW

Identifies the Unit of Work ID (UOW) of the DTC transaction. UOW is a character string that may be obtained from the syslockinfo table, which gives the UOW for every lock held by a DTC transaction. UOW also may be obtained from the error log or through the DTC monitor. For more information on monitoring distributed transactions, see the MS DTC user manual.

위 UOW ID를 찾는 방법은 아래 쿼리에서 찾으면 된다.

Use master

GO


/* Works on SQL Server 2005 and Higher Versions */


SELECT 

    DISTINCT(request_owner_guid)

FROM sys.dm_tran_locks

    WHERE request_session_id IN (-2,-3,-4)

GO


/* Works on SQL Server 2000 and Higher Versions */


SELECT 

    DISTINCT(req_transactionUOW)

FROM master..syslockinfo 

    WHERE req_spid IN (-2,-3,-4)

GO

[참고문서]

Kill Negative SPID in SQL Server
http://www.mytechmantra.com/LearnSQLServer/Kill-Negative-SPID-in-SQL-Server/

KILL
https://technet.microsoft.com/en-us/library/aa933230(v=sql.80).aspx





댓글
최근에 올라온 글
최근에 달린 댓글
글 보관함
Total
Today
Yesterday