SQL Server 101 – How to Find Currently Running Query ?

If you want to find currently running SQL Query in SQL Server, you can use the Dynamic Management View dm_exec_requests in SQL Server 2005 and later.

How to Find Currently Running Query in SQL Server ?

This returns the record for each request that is currently executing. You can display the actual SQL that is executing by doing a cross apply to sys.dm_exec_sql_text.

Below is a sample SQL query that finds the currently running Query in SQL Server.

SELECT SQLT.TEXT,
REQ.session_id,
REQ.status,
REQ.command,
REQ.cpu_time,
REQ.total_elapsed_time
FROM sys.dm_exec_requests AS REQ
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS SQLT
Copy link
Powered by Social Snap