Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I need to move a database log file to a new partition without taking the database offline.

The normal way of doing this would be to detach the DB, move the log file then reattach the db.

Is it possible to do this without taking the database itself offline and if so how?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

There is no way to do this with an online database.

When you move a database file (ALTER DATABASE ... MODIFY FILE), you even get the following message:

The file "YourFile" has been modified in the system catalog. The new path will be used the next time the database is started.


The normal way of doing this would be to detach the DB, move the log file then reattach the db.

That's not the "normal" or accepted way I would do it. To move database files, I do the following:

  1. Run an ALTER DATABASE command to change the location of the file(s)
  2. Take the database offline
  3. Physically move the file(s) to the new location specified in step #1
  4. Bring database online

See this reference on TechNet: Move User Databases

share|improve this answer
    
Well alrighty then. Thanks. –  Chris Lively May 6 at 17:42
    
+1 especially for (emphasis mine) NO DO NOT USE DETACH –  Aaron Bertrand May 6 at 19:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.