SQL Scripts to find Locked table in SQL Server 2005/2008
Script for the list of tables which are being locked :
select object_name(resource_associated_entity_id) as 'TableName',*
     from sys.dm_tran_locks where resource_type = 'OBJECT'
     and resource_database_id = DB_ID()
Script for list of tables with schema mode change lock :
select object_name(resource_associated_entity_id) as 'TableName',*
     from sys.dm_tran_locks where resource_type = 'OBJECT'
     and resource_database_id = DB_ID()
     and request_mode = 'Sch-M'
 

No comments:
Post a Comment