September 23, 2014 at 1:48 pm
Hi all,
Been asked to restore an orphaned MDF file leftover after a botched uninstall - no .bak file. Tried to reattach, but got an error, I don't think it had been detached. My initial answer was, "No, very likely can't be done".
Am I right? Or is there a way of attaching it that doesn't require it to have been detached?
Cheers,
Jake.
September 23, 2014 at 1:58 pm
What was the error that was generated?
You can attach a .MDF file using sp_attach_single_file_db:- http://msdn.microsoft.com/en-us/library/ms174385.aspx but it does require that the database was shutdown in a controlled fashion.
September 23, 2014 at 2:14 pm
You can attach the database using CREATE DATABASE FOR ATTACH_REBUILD_LOG.
http://msdn.microsoft.com/en-us/library/ms176061.aspx
If that doesn't work, you can try the undocumented FOR ATTACH_FORCE_REBUILD_LOG.
CREATE DATABASE <YOURDBNAME>
ON (FILENAME = 'D:\<YOURMDFNAME>.mdf')
FOR ATTACH_FORCE_REBUILD_LOG
September 23, 2014 at 4:01 pm
Intriguing, will try it out guys and let you know 🙂
September 24, 2014 at 2:44 pm
Fellas, it worked, passing you a big thank you from my management, who dragged me out for a few free beers as a result!!!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply