What are all the Objects being locked, From which machine, By which query

Posted by PandianS under Sql Server category on | Points: 40 | Views : 2029
Use DotNetFunda
SELECT S.[HOST_NAME]'Machine Name',
OBJECT_NAME(L.resource_associated_entity_id) 'Object Name',
L.request_mode 'Request Mode',
Q.[text] 'Query Used'
FROM sys.dm_tran_locks L JOIN sys.dm_exec_sessions S
ON (L.request_session_id = S.session_id)
JOIN sys.dm_exec_connections C
ON (C.session_id = S.session_id)
CROSS APPLY sys.dm_exec_sql_text(C.most_recent_sql_handle) Q
WHERE L.resource_database_id = DB_ID()
AND L.resource_type IN ('OBJECT')

Comments or Responses

Login to post response