My database has data and log files on the same physical disk array. I'd like to put the log file on a separate RAID array. What's the quickest way to move the log file?

Using sp_detach_db is the quickest and easiest way to move the log file. You can remove a log file from a database by using DBCC SHRINKFILE and ALTER DATABASE, but that technique takes longer. With sp_detach_db, you can quickly detach the database from the server, then reattach it by using sp_attach_db, specifying a new location for the physical log file. You should take care when moving files in a production database because you don't want to make a mistake that would cause downtime. You can find examples of how to use sp_detach_db in SQL Server Books Online (BOL).

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

This will not be the quickest if the database has full-text search enabled...

Rupert Wilson

I agree, but there is a hack to take the FT info along too

Kyoki

Article Rating 3 out of 5

No Links to examples?

athibodeau

Article Rating 1 out of 5

MS SQL 2000 - This is the error I get when attempting to attach the database after moving the logfile to a new location: Server: Msg 5173, Level 16, State 2, Line 1 Cannot associate files with different databases.

wchaster@willcsolutions.com

Article Rating 2 out of 5