Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there is a way to find out the number of active locks held on a table in SQL Server?

share|improve this question

migrated from Apr 2 '13 at 0:13

This question came from our site for professional and enthusiast programmers.

Have you looked at DMVs like sys.dm_tran_locks? Where have you looked? – Aaron Bertrand Apr 1 '13 at 21:20
up vote 11 down vote accepted

Here is a start. Remember that locks can go parallel so you may see the same object being locked on multiple resource_lock_partition values.

USE yourdatabase;

SELECT * FROM sys.dm_tran_locks
  WHERE resource_database_id = DB_ID()
  AND resource_associated_entity_id = OBJECT_ID(N'dbo.yourtablename');

Please look at the documentation for sys.dm_tran_locks

share|improve this answer
I I just noticed that the above answer gives the number of locks on the table but does not give locks on pages and entities on that table. Is there a way to get those locks as well? – Abdul Rahman Apr 5 '13 at 21:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.