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

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...