One of the many tasks of anybody who works more in depth with databases is the restoring of data.

Not being completely adept at this practice myself – mostly because it is rare that we administrate production databases – it is something I’m looking into at times.
Occasionally – I’ve seen databases being stuck in “Restoring” state. Basically without getting all to technical (because that’ll be a blog piece for another time), it is mostly because the Database is restored with the “NORECOVERY” clause, so it is ready to be rolled forward with transaction log backups.

So – a method of bringing a database back from restoring state is to run the script:
RESTORE DATABASE <DATABASE_NAME>

WITH RECOVERY

This has worked for me so far anyways… :)

19 Responses to “Bringing a database out of Restoring state in SQL Server 2005”

  1. Perfect! Worked great for me! Thanks..

    Raymond

  2. Kewl it worked for me as well :)

    I removed mirroring for principal db and partner db got stuck into restoring state
    u gave me magic solution :)

    Sathy

  3. Glad it can help – had the issue myself and it bugged the heck out of me.

  4. No joy for me. I inherited a failed log shipping installatin from a previous DBA and when I executed the script the following error occured.

    "Msg 4333, Level 16, State 1, Line 2
    The database cannot be recovered because the log was not restored."

    I want to take the DB offline for a period, then archive it to offline storage and get disk space back. Noone who currently works here knows what the database is for, or if anyone uses it.

  5. Good stuff. Can I quote you on my blog?

  6. Awesome, worked like a charm.

  7. Very good article. I’ve found your blog via Bing and I’m really happy about the information you provide in your articles. Btw your blogs layout is really messed up on the Chrome browser. Would be cool if you could fix that. Anyhow keep up the good work!

  8. That worked for me. Thanks for the tip

  9. Cheers

  10. No love here either:

    Msg 4333, Level 16, State 1, Line 1
    The database cannot be recovered because the log was not restored.
    Msg 3013, Level 16, State 1, Line 1
    RESTORE DATABASE is terminating abnormally.

  11. Great job….putting this in my toolbelt of scripts.

  12. Right Solution

  13. This worked for me, just fine. Did have to close and reopen SQL to get the databases to not display as Restoring.

  14. Thank you for posting this!!

  15. super!!!! amazing tip…worked like a charm..

  16. Thanks for the post. Setup a transaction log backup job using database maintenance. Made the mistake of selecting “Back up the tail of the log, and leave the database in the restoring state” This left all the database in the restoring state after the first execution of the log backup. The RESTORE Database WITH RECOVERY resolved the issue.

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>