sql-serverbackuprestore

SQL-Server: Is there a SQL script that I can use to determine the progress of a SQL Server backup or restore process?


When I backup or restore a database using MS SQL Server Management Studio, I get a visual indication of how far the process has progressed, and thus how much longer I still need to wait for it to finish. If I kick off the backup or restore with a script, is there a way to monitor the progress, or do I just sit back and wait for it to finish (hoping that nothing has gone wrong?)

Edited: My need is specifically to be able to monitor the backup or restore progress completely separate from the session where the backup or restore was initiated.


Solution

  • Yes. If you have installed sp_who2k5 into your master database, you can simply run:

    sp_who2k5 1,1
    

    The resultset will include all the active transactions. The currently running backup(s) will contain the string "BACKUP" in the requestCommand field. The aptly named percentComplete field will give you the progress of the backup.

    Note: sp_who2k5 should be a part of everyone's toolkit, it does a lot more than just this.