Tuesday, July 22, 2025

Cool little script if you are doing a long restore

 Here's a cool little script to see where your restore script is at.


SELECT
session_id AS SPID,
command,
percent_complete AS [Percent Complete],
start_time AS [Start Time],
DATEADD(SECOND, estimated_completion_time / 1000, GETDATE()) AS [Estimated Completion Time],
total_elapsed_time / 1000.0 / 60.0 AS [Elapsed Minutes],
estimated_completion_time / 1000.0 / 60.0 AS [Remaining Minutes]
FROM sys.dm_exec_requests
WHERE command IN ('BACKUP DATABASE', 'RESTORE DATABASE');





Hope this helps someone.

No comments:

Post a Comment

Little script to see the backup history

 Today, I was teaching a co-worker how to create a copy only backup of a SQL Managed Instance database.  And I came up to use this script t...