Here is a quick script which will help users to identify locked tables in the 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
When you run above script, it will display table name and lock on it.
I have written code to lock the person table in the database. After locking the database, when I ran above script – it gave us following resultset.
Reference:Â Pinal Dave (https://darkslategrey-bat-805937.hostingersite.com)