Move NAV SQL Log File to another drive

itinkiamitinkiam Member Posts: 37
edited 2009-03-03 in SQL General
Sorry if this is posted, but I couldn't find it. I've got a simple SQL 2005, single file database which includes the .mdf,.ndf and .ldf. I need to move the log file. I've found the following online:

Detach the database
use master
go
sp_detach_db 'mydb'
go


Move the file(s) and Reattach the database
use master
go
sp_attach_db 'mydb','E:\Sqldata\mydbdata.mdf','E:\Sqldata\mydblog.ldf'
go

:-k Question - perhaps obvious, do I change the attach statement to include the .ndf? I'll only be moving the .ldf.

thanks in advance

Comments

  • ara3nara3n Member Posts: 9,256
    I've attached databases manually through the GUI and in the intermediate process you can specify the log file. The scrip will look like this.
    USE [master]
    GO
    CREATE DATABASE [WIDE] ON 
    ( FILENAME = N'C:\temp\SQL\WIDE_Data.mdf' ),
    ( FILENAME = N'F:\WIDE_Log.ldf' ),
    ( FILENAME = N'C:\temp\SQL\WIDE_1_Data.ndf' )
     FOR ATTACH
    GO
    
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • garakgarak Member Posts: 3,263
    you can also do this in the Guid in the contextmenu if you click on the database self.
    Do you make it right, it works too!
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV/Navision' forum to 'SQL General' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • bbrownbbrown Member Posts: 3,268
    Create the new log file, then use ShrinkFile (with Move) on the old file. Then drop the old file.
    There are no bugs - only undocumented features.
Sign In or Register to comment.