What Is Locked

SELECT        Locks.request_session_id AS SessionID, Obj.name AS LockedObjectName, DATEDIFF(second, ActTra.transaction_begin_time, GETDATE()) AS Duration, ActTra.transaction_begin_time, COUNT(*) AS Locks
FROM            sys.dm_tran_locks AS Locks INNER JOIN
                         sys.partitions AS Parti ON Parti.hobt_id = Locks.resource_associated_entity_id INNER JOIN
                         sys.objects AS Obj ON Obj.object_id = Parti.object_id INNER JOIN
                         sys.dm_exec_sessions AS ExeSess ON ExeSess.session_id = Locks.request_session_id INNER JOIN
                         sys.dm_tran_session_transactions AS TranSess ON ExeSess.session_id = TranSess.session_id INNER JOIN
                         sys.dm_tran_active_transactions AS ActTra ON TranSess.transaction_id = ActTra.transaction_id
WHERE        (Locks.resource_database_id = DB_ID()) AND (Obj.type = 'U')
GROUP BY ActTra.transaction_begin_time, Locks.request_session_id, Obj.name

Torna su
Categoria

SQL SERVER (988)


Autore

Marco Cecchetti


Data pubblicazione.

23/03/2021



Recensioni

Articolo non ancora recensito