Moving database log file | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Moving database log file

What is the correct steps to take to move a LDF File. I need to move it from the C: Drive to the E: Drive cause im running out of space on the c: drive. thanks
1. Take backup of database
2. Detach the database
3. Move the log file
4. Attach the database HTH. Gaurav
Edit : Removed the WITH MOVE Option
Will this command work after i detach database and copy the log file to the new location? exec sp_attach_db @dbname = ‘baan’,
@filename1 = ‘e:mssql7dataaan.mdf’,
@filename2 = ‘c:sql7dataaan.ldf’
I dont know how to use the MOVE Command.

Sorry about the WITH MOVE Command. COnfused the syntax. I think this should work. BTW you have changed the location of .mdf file and not .ldf file. Just a thought… HTH. Gaurav
Also since you have only one .mdf file, you can use sp_attach_single_file_db. See BOL for more info. Gaurav
exec sp_attach_db @dbname = ‘baan’,
@filename1 = ‘e:mssql7dataaan.mdf’,
@filename2 = ‘c:sql7dataaan.ldf’ Just a minor point.. looks like you have your drive letters mixed up, judging by your original post wanting to move LDF from C to E
For reference here’s a great KB on moving databases with detach/attach including system databases INF: Moving SQL Server Databases to a New Location with Detach/Attach
HTH Jasper Smith