데이터베이스에 잠금이 해제된 구체적인 대상을 보기

2182 단어 데이터베이스
다음 스토리지 프로세스를 수행합니다.
SELECT CAST (

    REPLACE (

        REPLACE (

            XEventData.XEvent.value ('(data/value)[1]', 'varchar(max)'),

            '<victim-list>', '<deadlock><victim-list>'),

        '<process-list>', '</victim-list><process-list>')

    AS XML) AS DeadlockGraph

FROM (SELECT CAST (target_data AS XML) AS TargetData

    FROM sys.dm_xe_session_targets st

    JOIN sys.dm_xe_sessions s ON s.address = st.event_session_address

    WHERE [name] = 'system_health') AS Data

CROSS APPLY TargetData.nodes ('//RingBufferTarget/event') AS XEventData (XEvent)

    WHERE XEventData.XEvent.value('@name', 'varchar(4000)') = 'xml_deadlock_report';


결과는 XML로 반환되며, 두 번 클릭하면 자세한 결과 세트가 표시됩니다.
결과 집중에서 'ID' 방면의 노드를 찾을 수 있습니다: < inputbuf > 얻은 두 ID를 아래에 대응하는 곳에 두면 구체적으로 자물쇠가 사라진 대상을 찾을 수 있습니다
select OBJECT_NAME([Object Id],[Database Id])


 
잠금 상세 정보를 보려면 다음과 같이 하십시오.
SELECT L.request_session_id AS SPID, 

	DB_NAME(L.resource_database_id) AS DatabaseName, 

	O.Name AS LockedObjectName, 

	P.object_id AS LockedObjectId, 

	L.resource_type AS LockedResource, 

	L.request_mode AS LockType, 

	ST.text AS SqlStatementText, 

	ES.login_name AS LoginName, 

	ES.host_name AS HostName, 

	TST.is_user_transaction as IsUserTransaction, 

	AT.name as TransactionName, 

	CN.auth_scheme as AuthenticationMethod 

FROM sys.dm_tran_locks L 

	JOIN sys.partitions P ON P.hobt_id = L.resource_associated_entity_id 

	JOIN sys.objects O ON O.object_id = P.object_id 

	JOIN sys.dm_exec_sessions ES ON ES.session_id = L.request_session_id 

	JOIN sys.dm_tran_session_transactions TST ON ES.session_id = TST.session_id 

	JOIN sys.dm_tran_active_transactions AT ON TST.transaction_id = AT.transaction_id 

	JOIN sys.dm_exec_connections CN ON CN.session_id = ES.session_id 

	CROSS APPLY sys.dm_exec_sql_text(CN.most_recent_sql_handle) AS ST WHERE resource_database_id = db_id() 

	ORDER BY L.request_session_id 


  
 
 
 

좋은 웹페이지 즐겨찾기