TSQL: Estimated database restore completion

Warning: count(): Parameter must be an array or an object that implements Countable in /home/fbsqlcom/public_html/youdidwhatwithtsql.com/wp-content/plugins/wp-codebox/main.php on line 31

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],
		DATEADD(SECOND, r.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]) st

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

Leave a Reply