Restoring a database if it was not detached properly

Total Post:39

Points:273
 1243  View(s)
Ratings:
Rate this:
I had problems with my harddisk on my dev box, yet I was able to save my MDF and LDF files. These were not detached properly.

I tried  sp_attach_single_file_db  which broke down with the following error:

SQL Server detected a logical consistency-based I/O error: invalid protection option. It occurred during a read of page (0:0) in database ID 0 at offset 0000000000000000 in file 'FILENAME'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
I also tried to create a new database with the same size, stop the service, and overwrite the new mdf with the old mdf. But after starting the server, the database is not suspected, when i look at its properties its status is "shutdown".

I use SQL 2008
  1. Post:397

    Points:3117
    Re: Restoring a database if it was not detached properly

    Can you bring the database up in emergency mode?

    ALTER DATABASE YourDatabase
    SET EMERGENCY
    If you can then you can run a DBCC on the database and see just how bad the corruption is.

    If the hard drive was that hosed, the database may to badly damaged to do anything with

Answer