denrepo

SQL ServerSessions

Currently running requests

Every user request executing right now, with waits, blocker and the exact statement being run. First stop when someone says the server is slow.

Not yet verified. How scripts are tested

b-mssql-active.sql
1SELECT r.session_id, s.login_name, s.host_name,2       DB_NAME(r.database_id) AS database_name,3       r.status, r.command, r.wait_type, r.wait_time,4       r.blocking_session_id, r.cpu_time,5       r.total_elapsed_time / 1000 AS elapsed_sec, r.logical_reads,6       SUBSTRING(t.text, (r.statement_start_offset / 2) + 1,7         ((CASE r.statement_end_offset WHEN -1 THEN DATALENGTH(t.text)8           ELSE r.statement_end_offset END - r.statement_start_offset) / 2) + 1) AS running_statement9FROM sys.dm_exec_requests r10JOIN sys.dm_exec_sessions s ON s.session_id = r.session_id11CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t12WHERE r.session_id <> @@SPID13  AND s.is_user_process = 114ORDER BY r.total_elapsed_time DESC;

Paste it into your query tool.

Open in denrepo

More SQL Server scripts: Sessions