Move mdf file when DB is Online

  • Is there a way to move mdf and log file to another drive when the database is in use.

    I am trying to gain some space on the drive by moving db files to a different drive by making a copy of that file on another drive and once copied i want to attach database to the file on new drive.

    thanks

  • No, you can't move the file while the DB is online. You can add another file to the filegroup, and then shrink the data out of the existing one using the Emptyfile option, and move the data to the new file and then drop the older file, but this is very IO heavy, will likely cause performance problems, and generally not recommended as a best practice.

    Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
    My Blog | Twitter | MVP Profile
    Training | Consulting | Become a SQLskills Insider
    Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]

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

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