Skip to content
← Blog
🔒 All in your browser 🚫 No uploads stored
Guide

Finding and Resolving Blocking Queries in SQL Server

Bill Crawford — Guide — February 2026 — 10 min read  ·  Last updated October 17, 2025
Contents
  1. What is blocking?
  2. Blocking vs deadlock
  3. Using the query builder
  4. Ready-to-run diagnostic queries
  5. Resolving blocking
  6. Prevention strategies

Generate a blocking diagnostic query for your SQL Server.

Connect on LinkedIn →

Open Find Blocking Queries ↗

What Is Blocking?

In SQL Server, blocking occurs when one session holds a lock on a resource (a row, page, or table) that another session needs. The waiting session is blocked — it cannot proceed until the first session releases its lock. Brief blocking is normal and expected. Chronic blocking that lasts seconds or minutes indicates a performance problem.

Common causes include: long-running transactions that don't commit promptly, missing indexes that force table scans while holding locks, and implicit transactions left open by application bugs.

Blocking vs Deadlock

These are related but different problems:

Using the Query Builder

1
Enter your wait threshold

Set the minimum blocking duration in seconds. Sessions waiting less than this are ignored (brief waits are normal).

2
Choose what to include

Select whether to include the blocking query text, execution plan, login information, and wait statistics.

3
Copy and run in SSMS

Run the generated query against your SQL Server instance. You need VIEW SERVER STATE permission.

Ready-to-Run Diagnostic Queries

Find all current blocking chains

SELECT
  blocking.session_id       AS blocking_session,
  blocking.status           AS blocking_status,
  blocking_sql.text         AS blocking_query,
  waiting.session_id        AS waiting_session,
  waiting.wait_type,
  waiting.wait_time / 1000  AS wait_seconds,
  waiting_sql.text          AS waiting_query
FROM sys.dm_exec_requests waiting
INNER JOIN sys.dm_exec_sessions blocking
  ON waiting.blocking_session_id = blocking.session_id
CROSS APPLY sys.dm_exec_sql_text(blocking.most_recent_sql_handle) AS blocking_sql
CROSS APPLY sys.dm_exec_sql_text(waiting.sql_handle) AS waiting_sql
WHERE waiting.blocking_session_id > 0
ORDER BY waiting.wait_time DESC;

Find the head of a blocking chain

-- Sessions that are blocking others but not themselves blocked
SELECT s.session_id, s.status, s.login_name, s.host_name,
       t.text AS current_query, s.open_transaction_count
FROM sys.dm_exec_sessions s
CROSS APPLY sys.dm_exec_sql_text(s.most_recent_sql_handle) t
WHERE s.session_id IN (SELECT DISTINCT blocking_session_id FROM sys.dm_exec_requests WHERE blocking_session_id > 0)
  AND s.session_id NOT IN (SELECT session_id FROM sys.dm_exec_requests WHERE blocking_session_id > 0);

Resolving Blocking

Prevention Strategies

Frequently Asked Questions

What permission do I need to run blocking queries?
You need VIEW SERVER STATE permission to query sys.dm_exec_requests and related DMVs. A sysadmin or server-level VIEW SERVER STATE grant is required. In Azure SQL Database, VIEW DATABASE STATE is sufficient.
How do I kill a blocking session?
Run KILL in SSMS, replacing with the session ID from the diagnostic query. This terminates the session and rolls back any open transaction. The waiting sessions will then proceed.
What is lock escalation?
SQL Server starts with row-level locks but escalates to table-level locks when a query holds too many row or page locks (default threshold: 5000 locks). Table locks block all other readers and writers. Index coverage prevents lock escalation by reducing the rows scanned.
Can I see the full query text of a blocking session?
Yes — use CROSS APPLY sys.dm_exec_sql_text(session.most_recent_sql_handle) to get the query text. For the full batch, use sys.dm_exec_input_buffer.

Related Tools

BC
Bill Crawford
Founder, Data Conversion Center

Bill Crawford is a data systems developer and technical founder with over 30 years of professional experience in accounting, finance, and business operations.

He holds a Bachelor's degree in Accounting and has spent more than three decades working within financial and operational environments. Over the past 10 years, he has been heavily involved in the development, implementation, and refinement of financial and enterprise data systems for both Fortune 500 companies and smaller organizations.

His work bridges finance and technology — combining deep domain knowledge in structured reporting and accounting workflows with hands-on SQL development and database architecture experience.

Bill founded DataConversionCenter.com to build practical, browser-based tools that simplify complex data challenges, including:

Rather than focusing on theoretical examples, his tools and articles are informed by real-world challenges encountered in enterprise reporting systems, financial databases, and operational data environments.

Professional Background

Bill's mission is to reduce friction in data workflows — particularly for professionals working with structured financial, operational, and reporting data.