T-SQL Script to check the database backup and restore progress and estimated completion time
Script 1:
select
d.name as [Database Name],
Percent_complete,
dateadd(second,estimated_completion_time/1000,
getdate()) as EstimatedCompletionTime, Getdate() as Current_Time_now,
CAST((datediff(minute, start_time, getdate())) as varchar(50)) +' ' + 'Minutes' as CMD_Running_From,
CAST((estimated_completion_time/1000/60) as varchar(50)) +' ' + 'Minutes' as Will_Complete_in,
start_time as CMD_Start_Time,
command As Running_Command
from sys.dm_exec_requests req
inner join sys.sysdatabases d on d.dbid = req.database_id
where
req.command in ('RESTORE DATABASE', 'BACKUP DATABASE', 'RESTORE LOG', 'BACKUP LOG')
Script 2:
select
d.name,
percent_complete, dateadd(second,estimated_completion_time/1000, getdate()) as EstimatedCompletionTime, Getdate() as now,
datediff(minute, start_time, getdate()) as running, estimated_completion_time/1000/60 as togo,
start_time, command
from sys.dm_exec_requests req
inner join sys.sysdatabases d on d.dbid = req.database_id
where
req.command in ('RESTORE DATABASE', 'BACKUP DATABASE', 'RESTORE LOG', 'BACKUP LOG')
Comments
Post a Comment