---
title: "Restoring a database if it was not detached properly"  
description: "Restoring a database if it was not detached properly"  
author: "Anonymous User"  
published: 2015-09-26  
updated: 2015-09-26  
canonical: https://www.mindstick.com/forum/33472/restoring-a-database-if-it-was-not-detached-properly  
category: "mssql server"  
tags: ["database", "mssql server"]  
reading_time: 2 minutes  

---

# Restoring a database if it was not detached properly

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](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing):\

```
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](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) with the same [size](https://www.mindstick.com/forum/159799/how-can-you-manage-the-size-of-mdf-and-ldf-files), stop the [service](https://www.mindstick.com/articles/105963/online-thesis-writing-service-for-college-kids-with-disabilities), and overwrite the new mdf with the old mdf. But after [starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) the [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over), the database is not suspected, when i look at its [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties) its [status](https://www.mindstick.com/articles/157184/check-lic-policy-status-online-by-policy-number) is "[shutdown](https://yourviews.mindstick.com/view/80957/time-to-shutdown-wet-markets-of-china)".\
I use [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) 2008

## Replies

### Reply by Anonymous User

Can you bring the database up in emergency mode?\

```
ALTER DATABASE YourDatabaseSET 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\


---

Original Source: https://www.mindstick.com/forum/33472/restoring-a-database-if-it-was-not-detached-properly

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
