How to Find Currently Running Query in SQL Server

Channel: Linux
Abstract: req.session_idThe query is being executed. session_id

This can be an important query for your while debugging slowness of SQL server. This will help you find currently running SQL queries on SQL Server. You can find which queries are running from a long time and utilizing CPU.

To run this query, start SQL Server Management Studio, Open New Query window and copy below query in it. Now click on Execute button to run this query.

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

Run the above query using SQL server management studio. The result will be different than below screenshot.

Output Details:

TEXT: The query is being executed.
session_id: Session id assigned to query. We can use this id to kill this query
status: Current status of the query
Start_time: The time query was started.

Ref From: tecadmin
Channels: SQL SErverquery

Related articles