Posts filed under 'DATABASE'

Missing log file on SQL Server

Alhamdulillah,
To day is my lucky day i think, I lost my log file (.ldf) on my db and because of that I can’t asccesing my db. How a pity I’m (huh). Thus I found blog from spaceprogram.com, the article talking about “Recovering from a deleted log file on SQL Server”. And step by step I try to run the step given by the article with my friend “Agung”…….wow it’s working. I mean that finally I get back my data base, I can acces the data and run my application. You can find the original article below :
http://www.spaceprogram.com/knowledge/2002/06/recovering-from-deleted-log-file-on_12.html

And this is the step :
1. Backup the data (.mdf) file! Just in case. We take no responsibilityfor anything that happens following this procedure.
2. EXEC sp_detach_db ‘dbname’ — this will detach the database fromthe server
3. Restart SQL ServerThe database may still be seen in enterprise manager, but just ignoreit.
4. Create a new database with the same name or a different name. Youwill have to use a different physical file name, which is fine.
5. Stop SQL Server.
6. Rename the new data file that was created to something else (ex: add.bakto the end)
7. Rename the old data file that you want to restore to the name of thenewly created file (the same name as the file you changed in the stepabove)
8. Start SQL ServerNow the db will still be suspect but you now have a log file.
9. Switch to emergency mode on the database. You do this by doing thefollowing:
a. Right click on the database root node in Enterprise manager andbring up the properties.
b.Under the Server Settings tab, check of “Allow modificationsto be made directly to the system catalogs”.
c. click ok
d. Now go to the master database and open the sysdatabasestable.
e. Find the suspected database in here and modify the status column,setting it to: 32768. This will put it into emergency mode.
f. stop then start sql server
10. Now here’s the tricky part and I’m not sure how this will work ona single install, i was lucky enough to have SQL Server 2000 installed.But anyways, open up the Import and Export Data (DTS) program from thestart menu. And you want to copy data from the old database to a brandnew one. Just copy tables and views.

thanks for spaceprogram.com

Add comment August 6, 2007


Top Posts

Categories

RECENT POSTS

Recent Comments

Archives

Blog Stats

Meta