- First make sure that database is in suspect mode
- Create a new empty database at some safe location
- Now stop the SQL Server service
- Replace the old MDF file over newly created
- Start SQL service and database will try to recover it. (During this database will go to suspect mode)
- Now we will put the database to emergency mode (This can be done by using ALTER DATABASE or following commands)
GO
Reconfigure with override
GO
Update sysdatabases set status = 32768 where name = '
sp_dboption '
GO
Sp_configure 'allow updates', 0
GO
Reconfigure with override
GO
- Try to use DBCC CHECKDB ('
', REPAIR_ALLOW_DATA_LOSS) This will rebuild log file and run full repair of the MDF file)
- Then use DBCC REBUILD_LOG ('
','new LDF path') to rebuild the LDF file
- Almost done. Now we will push database to normal mode (Again use either ALTER DATABASE or following commands)
GO
Reconfigure with override
GO
Update sysdatabases set status = 16 where name = '
G
Sp_configure 'allow updates', 0
GO
Reconfigure with override
GO
- Restart the engine of Microsoft SQL Server (I have successfully checked on Microsoft SQL 2000)
- Verify your database by checking its tables and data.