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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restore Database

Status
Not open for further replies.

ekta22

IS-IT--Management
May 3, 2004
359
US
Hi All:

By mistake I deleted the SQL Server database from Enterprise Manager. But I still have the datafiles, .mdf and .ldf on the C: drive. I can't figure out as how to rebuild the database using those 2 files. I would appreciate if anyone can help me with this. It is very urgent.

Thanks,

Ekta
 
See sp_attach_db and sp_attach_single_file_db.

Might not work if these file were not detached (and even if they were).
Better to restore a backup.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
If you are using SQL 2000 you may be able to righ click on the database folder inside of SQL manager select all task and Attach database then browse to your .mdf file
 
Thanks for replying.
Nigelrivett. I didn't understand
"See sp_attach_db and sp_attach_single_file_db". I am very new to this. Could you please explain this a little more.

Transmit, I tried what you told me. But when I select Attach database and browse to the .mdf file it gives me an error message that says:
"The file you've specified is not a valid SQL Server database file"
Any idea as to why it is giving me this error?

 
Make sure that you have selected the .mdf file It should find the .ldf file automaticly. If you did select the .mdf file and got that error message it is posible that it is curupt and you may have to restore from backup wich you can do from all task also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top