Last active
August 26, 2022 21:44
-
-
Save petesql/2385ca22d7ee211b045904e34ea082c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get estimated backup & restore time | |
SELECT | |
r.session_id, | |
r.user_id, | |
r.start_time, | |
dateadd(second,estimated_completion_time/1000, getdate()) as estimated_completion_time, | |
r.percent_complete, | |
r.command, | |
d.name, | |
s.text AS full_command_text | |
FROM sys.dm_exec_requests r | |
JOIN sys.databases d ON r.database_id = d.database_id | |
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s | |
CROSS APPLY sys.dm_exec_input_buffer(r.session_id, r.request_id) AS ib | |
WHERE 1=1 | |
AND r.command IN ( | |
'RESTORE DATABASE', | |
'BACKUP DATABASE', | |
'RESTORE LOG', | |
'BACKUP LOG', | |
'DbccSpaceReclaim', | |
'DbccFilesCompact'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment