Check long running queries in SQL Server

Check the SQL statements having high elapsed time in SQL Server

SELECT text AS QueryText,
 total_elapsed_time / 1000 AS DurationMs
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle)
order by 2 desc;

Identifies slow running queries in SQL Server


SELECT 
 r.session_id,
 r.start_time,
 r.status,
 r.command,
 r.cpu_time,
 r.total_elapsed_time,
 r.reads,
 r.writes,
 r.logical_reads,
 r.text_size,
 r.plan_handle,
 s.text
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s
WHERE r.status = 'running'
ORDER BY r.total_elapsed_time DESC;

Check long query in SQL Server Management Studio:

Using SQL Server Management Studio (SSMS):
o Open SSMS and connect to the SQL Server instance.
o Navigate to Management > Activity Monitor.
o In the Activity Monitor, expand the Processes pane. Here, you can see the
currently running queries and their duration.

This entry was posted in MSSQLServer on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply