Get Lock Activity In SQL Server 2008

In this article I will explain about viewing lock activity in SQL Server.
  • 1459

In this article I will explain about viewing lock activity in SQL Server.

To monitor locking activity, open query editor window and run following code:

USE person

BEGIN TRAN

SELECT * FROM Employee

WITH (TABLOCKX)

This will give following result:

TableLock1.jpg

Now write following query and execute.

SELECT request_session_id sessionid,

resource_type type,

resource_database_id dbid,

OBJECT_NAME(resource_associated_entity_id) objectname,

request_mode rmode,

request_status rstatus

FROM sys.dm_tran_locks

This will return information about locking session identifier,databases , objects, rmode and lock status.

 TableLock2.jpg

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.