TSQL: Estimated database restore completion
Here’s a query proving you approximate percentage compeled, and estimated finish time, of any database restores happening on a SQL Server instance…
SELECT st.[text],
r.percent_complete,
DATEADD(SECOND, r.estimated_completion_time/1000, GETDATE()) AS estimated_completion_time,
r.total_elapsed_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) st
WHERE [command] = 'RESTORE DATABASE';
The resultset will look something like below…
text percent_complete estimated_completion_time total_elapsed_time
RESTRE DATABASE d... 47.57035 2014-08-08 13:49:48.373 958963