Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Quick Help needed
Message
 
À
21/08/2002 09:02:42
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Recouvrement
Divers
Thread ID:
00691775
Message ID:
00692514
Vues:
25
I once had to recover a .mdf with a corrupt .ldf and these are the steps I followed. They are not published anywhere and it took about 2 hours on the phone with Microsoft to get it. It has worked for me 2 out of 4 times.

I wish they pubished more recovery stuff in BOL rather than the generic procedures. I think this was thought up by a person who knows a lot more than I ever will.

Good luck.

***************************************************
Steps to recover .mdf file with a corrupt .ldf file

Run the statements in Query analyzer and perform the other tasks in Enterprise manager and a command prompt/explorer.

1. Run the following statement once: sp_configure ‘allow updates’,1.
2. Run the following against master: sp_reconfigure with ‘override’.
3. Questioned database should be restored from backup if not already on server. Databases will show a loading or suspect attribute in the server tree window.
4. Detach corrupt files and rename to a safe name.
5. Create a new database, example ‘TESTDATA’, with size set to minimum default.
6. Stop SQL Server.
7. Rename the newly created database files to a safe name. Do not detach!
8. Rename the corrupt files ( .mdf, .ldf , and any .ndf’s) to the file names you just created in step #3.
9. Run a select statement against master database: select * from sysdatabases where name = ‘database name’. Status may reflect loading or other non-viable code.
10. Run the following: Update sysdatabases set status = 32768 where name = ‘database name’. This will set the status to emergency.
11. Stop and immediately restart SQL Server.
12. Rename log file or delete it with SQL running and do not detach.
13. Run the following: dbcc rebuild_log ( ‘database name’,’desired path and name of log file’). Example: dbcc rebuild_log ( ‘TESTDATA’,’f:\data\TESTDATA_Log.ldf’)
14. Optional: run dbcc checkdb(‘database name’).
15. Run the following: Update sysdatabases set status = 0 where name = ‘database name’. This will set the status to normal.
16. Optional: run sp_helpdb to check to database.

You should now be able to read the tables and retrieve your data.

Repeat step 3-16 as needed for file corruption.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform