Shadow76
8/18/2015 - 3:18 PM

Identify Locked Table

Identify Locked Table

SELECT
  OBJECT_NAME(p.OBJECT_ID) AS TableName,
  resource_type, resource_description
FROM sys.dm_tran_locks l
JOIN sys.partitions p 
  ON l.resource_associated_entity_id = p.hobt_id
  
SELECT * 
FROM sys.dm_exec_requests CROSS APPLY sys.dm_exec_sql_text(sql_handle) 
WHERE session_id IN 
(
  SELECT blocking_session_id 
  FROM sys.dm_exec_requests 
  WHERE DB_NAME(database_id)='?' and blocking_session_id <>0
)