Search This Blog

Tuesday, December 18, 2012

Find locked tables SQL Server

SQL Server > Dynamic Management Views and Functions > sys.dm_tran_locks

Returns information about currently active lock manager resources in SQL Server. Each row represents a currently active request to the lock manager for a lock that has been granted or is waiting to be granted.

Example:

Find locked tables SQL Server

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