Skip to Content

MSSQL 2005 - Change path where LDF and MDF file are stored

Dear all.

I need som advice.

I need to change the path where all file *.MDF and *.LDF are store.

Now my configuration store all these files in E:/programs/MSSQL.1/MSSQL/data/

I need to change the above path in something like D:/MSSQL/data/.

What is the best way to do this safely?

--SAPB1 2007 A SP01 PL10


Thank's in advance and sorry for my english!!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 27, 2010 at 10:41 AM


    You have two options

    (1) You can backup and restore your database; by using the WITH MOVE options you can relocate files.

    (2) You can detach your database, move the database files to the desired location, re-attach the database.

    Take back up of data bases before performing any step .follow below procedure:

    Right click my database, select Tasks , Detach, and check Drop

    Using Windows Explorer, copy the existing Primary Data File, Secondary Data File, and Transaction Log from location on E drive

    Paste these files into new folder on D drive

    In Studio, right click Database and select Attach, Add, and select mdf file in drive D



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 27, 2010 at 09:55 AM


    Have you install new instance of SQL??

    If you want to change path then you req to put your MDF & LDF files to that new path.

    After that detach your original DB & Attach MDF file with reference to new path on Database using SQL Server Management Studio

    it will work for you



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.