Sql-server – Read committed snapshot:Finding lock on table

lockingsql servertransaction

IF update command is run on a table and commit is pending then another user cannot be able to update the table.

Is there any query to get the user or PC which caused lock on the table.

Best Answer

It is possible to list the locks using the DMV sys.dm_tran_locks (sp_lock is deprecated).

The DMV query can be hard to code against and the results can be difficult to interpret. Consider using the free sp_WhoIsActive tool from Adam Machanic instead. He explains how to use it to analyse chains of blocking locks in this blog post (which also contains a download link).