---
title: "How to Recover from a Corrupted Database in SQL Server 2000"  
description: "Make sure that the database being restored is from the same Product level as the server you are restoring to. I once faced an issue when trying to res"  
author: "AVADHESH PATEL"  
published: 2012-09-06  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/355/how-to-recover-from-a-corrupted-database-in-sql-server-2000  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# How to Recover from a Corrupted Database in SQL Server 2000

Make sure that the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) being restored is from the same Product level as the server you are restoring to. I once faced an issue when trying to restore a database from an SP4 to a non-SP4 database server.

1. Detach the corrupted MDF from [Enterprise](https://www.mindstick.com/blog/246/enterprise-java-beans-ejb) Manager. \
\
2. Save the corrupted MDF to a safe [location](https://www.mindstick.com/blog/11636/relocating-business-or-office-to-another-location). \
\
3. Now create a new database with the same name (the location must be the same as the “corrupted MDF and LDF”. \
\
4. Stop the [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) service. \
\
5. Now replace this MDF and LDF (new database) with the “corrupted MDF and LDF”. \
\
6. Start SQL Server. \
\
7. Launch Enterprise Manager. Now you should be able to see the database in suspect mode. \
\
8. Launch Query Analyzer and select the master database. Issue the following [commands](https://www.mindstick.com/interview/817/what-is-the-use-of-dbcc-commands) in this order:

```
sp_configure ‘allow updates’, 1go  reconfigure with overridego
```

9. You can now make changes to the system catalog tables. \
\
10. Now to check the status of our database. Issue the following command \
\
select status from sysdatabases where name=’your database name’ (replace with your database name) \
\
11. Now execute the following command:

```
update sysdatabasesset status = 32768 where name=’your database name’
```

12. Next restart SQL Server Service. \
\
13. You will now be in [Emergency](https://www.mindstick.com/news/2561/iphone-14-emergency-sos-via-satellite-feature-expands-to-europe) Mode. \
\
14. Now create a [destination](https://yourviews.mindstick.com/story/1451/gorgeous-locations-for-destination-weddings-in-india) [recovery](https://www.mindstick.com/blog/23170/3-tips-on-applying-recovery-principles-to-building-a-successful-business) database, called dbrecover and try to push data from the corrupt database to the new dbrecover database using DTS. \
\
15. Now issue the following undocumented command:

DBCC rebuild_log (‘your database name’, ‘new log [filename](https://www.mindstick.com/interview/23463/difference-between-include-filename-and-include-filename) with path’)

16. After this successful [execution](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net), you will need to get into your database, so issue the following commands:

```
use mastergo  sp_dboption ‘your database name’,‘single_user’,’true’go  DBCC checkdb(‘your database name’,repair_allow_data_loss)go
```

17. Finally set your database back to a normal status by issuing the following command:

```
use mastergo update sysdatabasesset status=0 where name=’your database name’go
```

18. Now you can see that your database is back online!

19. As a precautionary measure, please disable updates the system catalogs immediately by issuing the following command:

```
use mastergo  sp_configure ‘allow updates’,0go  Reconfigure with overridego
```

This is how one recovers a corrupted mdf database and brings it back online.

---

Original Source: https://www.mindstick.com/blog/355/how-to-recover-from-a-corrupted-database-in-sql-server-2000

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
