Skip to content

Instantly share code, notes, and snippets.

@akramarev
Last active July 21, 2019 07:41
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 akramarev/58d070d2c0c6cd7814fa1fdfd417d1c2 to your computer and use it in GitHub Desktop.
Save akramarev/58d070d2c0c6cd7814fa1fdfd417d1c2 to your computer and use it in GitHub Desktop.
[Print out long running mssql backup/restore queries]
SELECT session_id as SPID, command, a.text AS Query, start_time, percent_complete, dateadd(second,estimated_completion_time/1000, 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','BACKUP LOG','RESTORE DATABASE')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment