Wednesday, 14 November 2012

Backup/Restore/Shrink percentage complete.


Ever wondered roughly how long your backup/restore or shrink file is going take - hopefully this snippet will help you.

SELECT  session_id ,
        percent_complete ,
        start_time ,
        command ,
        d.name ,
        DATEADD(ms, estimated_completion_time, GETDATE()) AS [est completion time] ,
        ( estimated_completion_time / 1000 / 60 ) AS [mins remaining]
FROM    sys.dm_exec_requests er
        INNER JOIN sys.databases d ON er.database_id = d.database_id
WHERE   command LIKE 'backup%'
        OR command LIKE 'restore%'
        OR command = 'DbccFilesCompact'

No comments:

Post a Comment