我们如何才能找到数据库中被锁定的表?请,建议。
问问题
143611 次
2 回答
87
您可以使用sp_lock
(and sp_lock2
),但在 SQL Server 2005 及以后的版本中,不推荐使用此方法,而支持查询sys.dm_tran_locks
:
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
于 2009-03-01T09:21:54.077 回答
8
When reading sp_lock information, use the OBJECT_NAME( ) function to get the name of a table from its ID number, for example:
SELECT object_name(16003073)
EDIT :
There is another proc provided by microsoft which reports objects without the ID translation : http://support.microsoft.com/kb/q255596/
于 2009-03-01T08:56:55.387 回答