Identify Block SPs

In a SQL Server there is two things Blocking and Locking. Today will check about blocking.

There are number of ways to find out the details of the system processes IDs (spids) involved in blocking. I have tried to cover some of the options in this tip to include:

  • sp_who2 System Stored Procedure

The sp_who2 system stored procedure provides information about the current SQL Server processes with the associated users, application, database, CPU time, etc. 

For Checking in SQL use below Query.

EXEC sp_who2
  • sys.dm_exec_requests DMV

The sys.dm_exec_requests DMV provides details on all of the processes running in SQL Server. With the WHERE condition listed below, only blocked processes will be returned.

SELECT * 
FROM sys.dm_exec_requests
WHERE blocking_session_id <> 0;
  • Sys.dm_os_waiting_tasks

The sys.dm_os_waiting_tasks DMV returns information about the tasks that are waiting on resources. To view the data, users should have SQL Server System Administrator or VIEW SERVER STATE permissions on the instance.

SELECT session_id, wait_duration_ms, wait_type, blocking_session_id 
FROM sys.dm_os_waiting_tasks 
WHERE blocking_session_id <> 0

Leave a comment

Design a site like this with WordPress.com
Get started