Skip to content

List blocking locks in SQL Server (MSSQL) Database

Problem

You use SQL Server and you need to know which sessions are blocked and for what reason.

Solution

Use the following query to get a list of blocked sessions.

SELECT p.cmd,
       p.*
  FROM sys.sysprocesses p
 WHERE blocked > 0

You can find this solution also as GitHub gist list-blocking-locks.sql.