Skip to content

Instantly share code, notes, and snippets.

@kmatt
Last active August 29, 2023 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmatt/809902 to your computer and use it in GitHub Desktop.
Save kmatt/809902 to your computer and use it in GitHub Desktop.
SQL Server execution status
SELECT R.session_id, DatabaseName = db_name(R.database_id), S.text, R.Status, R.Command,
R.percent_complete,
CAST(CAST(DATEADD(mi, R.total_elapsed_time/60000.0, 0) AS TIME) AS CHAR(5)) runTime,
CAST(CAST(DATEADD(mi, R.estimated_completion_time/60000.0, 0) AS TIME) AS CHAR(5)) remain,
R.reads, R.writes, R.cpu_time, R.status, R.wait_type
FROM sys.dm_exec_requests R
CROSS APPLY sys.dm_exec_sql_text(R.sql_handle) S
WHERE R.session_id <> @@SPID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment