Monday, September 9, 2024

How can I find out the currently running queries in SQL Server?

 Use the following query to find currently running queries:

SELECT r.session_id, r.start_time, s.text AS query_text, r.status, r.command, r.total_elapsed_time FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s;

This returns details about all currently running queries, including the session ID, query text, and execution status.