User:Lmengleang/sandbox

How to recover mdf in SQL Server 2008 when SQL Server get accident at some point.

1. re-install sql server

2. create new database with the same name to database to recover

3. stop sql server service

4. copy your old database (mdf not ldf) and replace the new

5. run script bellow one by one:

ALTER DATABASE YourDatabase SET EMERGENCY

ALTER DATABASE YourDatabase SET SINGLE_USER

DBCC CHECKDB (YourDatabase, REPAIR_ALLOW_DATA_LOSS)

ALTER DATABASE YourDatabase SET MULTI_USER

ALTER DATABASE YourDatabase SET ONLINE