HomeSQL ServerSQL Server 101 – How to Find Currently Running Query ?

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

You May Also Like

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...