How to Kill a Query in SQL Server

Last updated July 25, 2026 · By the SaturnSQL team

Find the session with sp_who2 or sys.dm_exec_requests, then terminate it with KILL followed by the session id. The killed session's transaction rolls back, which can take as long as the work it already did.

EXEC sp_who2;

Find long-running queries with their SQL text

SELECT r.session_id,
       r.status,
       r.total_elapsed_time / 1000 AS seconds,
       t.text
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE r.session_id <> @@SPID
ORDER BY r.total_elapsed_time DESC;

Kill the session

KILL 53;

-- check rollback progress
KILL 53 WITH STATUSONLY;

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related SQL Server guides

© 2026 Panda Capital Oy Ab. All rights reserved.