Skip to content

Instantly share code, notes, and snippets.

@paschott
Created March 7, 2026 12:53
Show Gist options
  • Select an option

  • Save paschott/80d0303b62d13072e539bf09a818ac50 to your computer and use it in GitHub Desktop.

Select an option

Save paschott/80d0303b62d13072e539bf09a818ac50 to your computer and use it in GitHub Desktop.
TSQL Backup and Restore Status
SELECT
session_id as SPID, command, a.text AS Query, start_time, percent_complete *1.0 as percent_complete,
dateadd(second,estimated_completion_time/1000.0, getdate()) as estimated_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE','BACKUP LOG','RESTORE LOG')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment