Share via


How to change LDF/MDF path

Question

Tuesday, June 6, 2017 3:55 PM

Hello,

When investigating a database related issue, we found that a third party supplier of ours has historically installed a database onto the C drive rather than the D drive.

As the database is growing, we need to move this from the C Drive onto (ideally) the D drive - is this possible?

Thanks.

All replies (6)

Tuesday, June 6, 2017 4:03 PM

Yeah, it is possible. Take a look at the article "SQL SERVER – Move Database Files MDF and LDF to Another Location".

A Fan of SSIS, SSRS and SSAS


Tuesday, June 6, 2017 4:07 PM

Hi,

Yes it is possible.

I will recommend to go with Alter database with desired location, take offiline, move files and bring online

https://technet.microsoft.com/en-us/library/gg452698.aspx?f=255&MSPPError=-2147217396

Thanks, Satish Kumar. Please mark as this post as answered if my anser helps you to resolves your issue :)


Tuesday, June 6, 2017 4:14 PM

You can detach the database, copy the files, and then re-attach them from the new location. Ensure that the log file going to use the current location.

Copy the files in case there is a problem with damaging the files so you can revert back to the original copy.


Wednesday, June 7, 2017 6:00 AM

  • Right click on the name of the database
  • Select Properties
  • Go to the Files tab
  • Make a note of the Path and FileName of MDF and LDF files. This step is important in case you don't want to end up searching for missing files...
  • Right click on the database name
  • Select Tasks -> Detach
  • Move the files where you want
  • Right click on the Databases node of your server
  • Select Attach
  • Click on the Add button
  • Point to the new location
  • Click OK

Wednesday, June 7, 2017 11:47 AM

Hi All,

Many thanks for your responses, great info.


Friday, June 16, 2017 1:36 AM

Hi Yetysaurus,

Glad to hear that you have resolved the issue. Please make corresponding replies as answer as it would benefit others when they are reading this thread. 

Regards,

Davy

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.