Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recovering DB - have ldf/mdf and old backup 1

Status
Not open for further replies.

swhitten

Technical User
Sep 3, 2002
191
US
A client called me today. Their server crashed. He wants to recover one of their sql 2k databases. Here's what we have - the ldf and mdf files and a backup from 2005.

How can I recover this db for him? I don't think I can just plug in the ldf and mdf files, but I don't know what else to do.

Thanks in advance for the help.
 
You have 2 choices. Attach the mdf to the server or restore the backup. Your choice

Yes, attaching the mdf is almost as easy as plugging it in. Right click the instance -- tesks -- attach database


[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
That sounds a whole lot easier than I thought it would be. What happens to the ldf if i attach only the mdf?

To attach the mdf, I start with nothing in SQL - I don't create an empty database first or restore this backup and attach the mdf into it or anything?

I've used attach/detach before but never to recover a db like this. Thanks again!
 
No you do not create a database first. Technically you're not recovering anything with attach. If you do not attach the ldf then it will create a new one.

If you ahve a database online rate now then the restore will probably be easier and perhaps safer in some respect. Just right click the database -- tasks -- restore database

Select from device and then find your .bak (or whatever its called). Just make sure you go to options and check to overwrite the current one. Also make sure no connections are live to the database

I don't remember off hand if there is a replace existing for attach.


[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Unfortunatly the backup is from September 2005, so by itself, it's not much help. I think I will try the ldf attach method.

Thanks again!!!!!
 
Thanks to you, I'm a hero :) The database is up and running. Attached ldf/mdf files. DB was suspect. Stopped and restarted SQL, and DB was fine. Made a good backup :) Reminded client to hang onto this backup.

I didn't realize you could just attach an MDF/LDF like that. Was that not true in SQL 7? I have always been told that if you only have an orphaned ldf/mdf from a db that you didn't detach first, you're out of luck. But obviously your method worked like a charm.

Thanks again!!!!!!!

 
:) Glad you got it up and going and thanks for the *


[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top