Wednesday, October 21, 2009

Recover SQL 2005 Corrupt Database

1) Detach database and move your mdf to save location.
2) Create new databse of same name, same files, same file location and
same file size.
3) Stop SQL server.
4) Swap mdf file of just created DB to your save one.
5) Start SQL. DB will go suspect.
6) ALTER DATABSE SET EMERGENCY
ALTER DATABASE SET SINGLE_USER
7) DBCC CHECKDB (, REPAIR_ALLOW_DATA_LOSS)
8) ALTER DATABASE SET MULTI_USER
ALTER DATABSE SET ONLINE

No comments: