Detach / Attach when db is in NORECOVERY mode

  • Hi

    Due to a script error, I accidentally detached a database today when it was in NORECOVERY mode (ie receiving log ship transaction logs)

    When I tried to reattach the database the attach command failed saying that its not possible to attach files when they are in NONRECOVERY mode.

    I ended up restoring the db from backup to get it back, but does anyone know how I could have got the db back from the mdf and ldf files?

    Thanks in advance

    Perry

  • Never heard of that, but I suspect that there isn't anything you can do. A detach in that phase would seem to suggest you had the backup files and could restore again. Since an attach does a roll forward/back, that can't complete because of the status.

  • If a database is detached while in the recovering or standby state, it cannot be reattached (baring some odd hacks that may or may not work)

    In fact, in SQL 2008, you cannot detach a recovering database.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If a database is detached while in the recovering or standby state, it cannot be reattached .

  • GilaMonster (5/23/2009)


    If a database is detached while in the recovering or standby state, it cannot be reattached (baring some odd hacks that may or may not work)

    Pradyothana Shastry (5/27/2009)


    If a database is detached while in the recovering or standby state, it cannot be reattached .

    Is there an echo in here?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If a database is detached while in the recovering or standby state, it cannot be reattached.

    Hope that helps.

    I can haz more posting pointz?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply