• subscribe
December 23, 2003 12:00 AM

Moving the Log File

SQL Server Pro
InstantDoc ID #40965

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).



ARTICLE TOOLS

Comments
  • Will
    5 years ago
    Sep 13, 2007

    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.

  • Andre
    6 years ago
    Jul 31, 2006

    No Links to examples?

  • Mike
    8 years ago
    Aug 05, 2004

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

  • Rupert Wilson
    8 years ago
    Jun 30, 2004

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

You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...