Can''t get a database into emergency mode

  • Environment:  SQL 2005 Developer Edition SP1

    We had a disk going bad on our development server.  We put a new disk in & began copying over the files hoping we would get them all before the drive was completely bad.  Well, we didn't make it.  So upon restart of SQL, it was missing log files or only partial log files were there.  So the database gave an error about not being able to open the log file.  At this point, I cannot click on the database & say restore.  Looking elsewhere, it appears that I have to put the database into emergency mode to do this.  So I used the following:

    Alter database mydatabase

    set emergency

    It comes back with an error about not having enough permissions or the database does not exist.  I am sysadmin so it shouldn't be a permissions issue.  If the database doesn't exist, why does it still show up in the list of databases?  I need some help with getting this database into emergency mode.  I could just delete the database & then restore but I don't think that would be a good practice.

    Any advice out there?

    John

  • If you are only missing log files, you should be able to stop the sql server, delete the existing log file in the windows file system, and then restart the sql server.  The sql server should just build a new log file for the database.  Of course, you will not have any data in the log file, but if the one you have was corrupt anyway you're already at that point.

  • Joshua Perry:

    you wrote:

    < The sql server should just build a new log file for the database. >

    FYI: sql server does not build a new log file for the database as part of restore as per your post

    ------

    laker_42 :

    http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_22006118.html

  • I did not say anything about a restore.  I said to stop the sql server, delete the log file, and then start the sql server to allow the server to create a new log file.  I have done this several times and it does work.  This guy did not have a problem restoring the mdf - he could not get the log restored.  You need to read what was actually written.

Viewing 4 posts - 1 through 3 (of 3 total)

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