Moving database files to another drive

  • Hi all

     

    For background, we ave two servers (DEV and PROD) and they are set up slightly differently.

    On DEV, the mdf files are stored on the E: drive, on PROD the mdf files are stored on the D: drive.

     

    What I'd like to do is change the drive on the DEV server to be D: to match the PROD server (we have some code that references the drives by letter that I have to remember to change when I push the code from DEV to PROD.

     

    I can easily move the user database files from one drive to another (I've got code for that).

    I'd like to move the system databases as well but I don't want to crash everything.

     

    Is the routine the same for moving the mdf's for the system databases the same as for user databases?

    I've attached my code for moving the user databases for reference.  It generates a script (with comments) that you run through in sections as you move the files around (any improvements on this would be appreciated) as we occassionally get databases created on the wrong drive.

     

    TIA

     

    Richard

    Attachments:
    You must be logged in to view attached files.
  • msdb, model, & tempdb can be moved through relatively normal means (though you have to restart SQL Server afterwards).

    master requires modifying startup parameters and the registry... and maybe a prayer 🙂

    See

     

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply