A couple of weeks back I posted a script that checks the progress of any backups running on and instance. A few days later I needed a script to check the progress of a restore. Fortunately enough, the backup script can be re-used with a very simple change. This simple script to check if any restores are running, how long they have been running and what the anticipated complete time will be.

Happy scripting!


SELECT A.NAME
,B.TOTAL_ELAPSED_TIME / 60000 AS [Running Time]
,B.ESTIMATED_COMPLETION_TIME / 60000 AS [Remaining]
,B.PERCENT_COMPLETE AS [%]
,(
SELECT TEXT
FROM sys.dm_exec_sql_text(B.SQL_HANDLE)
) AS COMMAND
FROM MASTER..SYSDATABASES A
,sys.dm_exec_requests B
WHERE A.DBID = B.DATABASE_ID
AND B.COMMAND LIKE '%RESTORE%'
ORDER BY percent_complete DESC
,B.TOTAL_ELAPSED_TIME / 60000 DESC