Search

Wednesday, July 27, 2011

Very useful code to check estimate time of Backup/Restores

This code, directly from Teched 2008:-), is very useful to have when restoring large databases. It gives info anout how much time etc it is left until the databse is restored. it also gives and aproximately time when the restore will be completed.

SET NOCOUNT ON
GO
SELECT Command
, 'PercentComplete' = percent_complete
, 'EstEndTime' = CONVERT(varchar(26),Dateadd(ms,estimated_completion_time,Getdate()),100)
, 'EstSecondsToEnd' = CONVERT(decimal(9,2),(estimated_completion_time * .001))
, 'EstMinutesToEnd' = CONVERT(decimal(9,2),(estimated_completion_time * .001 / 60))
, 'OperationStartTime' = CONVERT(varchar(26),start_time,100)
FROM sys.dm_exec_requests
WHERE command IN ('BACKUP DATABASE','RESTORE DATABASE')

No comments:

Post a Comment