Home > DeveloperSection > Forums > Restoring a database if it was not detached properly
Andrew Watson
Andrew Watson

Total Post:39

Posted on    September-26-2015 2:39 AM

 MSSQL Server Database  MSSQL Server 

 1 Reply(s)
 801  View(s)
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

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    September-26-2015 6:07 AM

Can you bring the database up in emergency mode?

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

Don't want to miss updates? Please click the below button!

Follow MindStick