Skip to main content

Useful MSSQL Queries

 

 

Show running queries

SELECT req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time,
sqltext.TEXT
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext

Kill running query

Get the session_id from the previous query, then use the KILL command:

KILL [session_id]

 

 

 

#end