Monday, September 15, 2014

Display ETA and Percent Completed for BACKUP or RESTORE Commands

This code will show you the estimated time of completion and percent completed for currently running BACKUP or RESTORE commands.

-- Shows both backups and restores.
select session_id                                      as 'spid'
     , command                                         as 'Command'
     , start_time                                      as 'StartTime'
     , (total_elapsed_time / 1000) / 60                as 'ElapsedMins'
     , cast(percent_complete as int)                   as '% Done'
     , convert(nvarchar,
               dateadd(ms, estimated_completion_time,
               current_timestamp), 120)                as 'ETA'
  from sys.dm_exec_requests
 where command like '%BACKUP DATABASE%'
    or command like '%RESTORE DATABASE%'

1 comments:

A said...

Nice. Thanks

Post a Comment