tags:

views:

59

answers:

2

Hi,

I need to move the transaction log for a database I have just created using aspnet_regsql.
Is it possible to move the transaction log using sqlcmd or any other command line tool?

kind regards,

A: 

You can always do what you want in the Management Studio and let it generate the SQL Statements for your action.

Tim Büthe
-1 But this can't be done using SSMS (will remove downvote if you prove me wrong:))
Andomar
@Andomar: Well, when you change the path of the file in the SSMS and generate the script, you get something like you suggested. That's what I meant.
Tim Büthe
On my SSMS, the path box is read-only? Under "Database properties -> Files"
Andomar
hmmm, I was sure I had done this. However, I have no SSMS by the hand. Nevermind, +1 for your answer.
Tim Büthe
Nick Kavadias
This will only change the declared location of the file, but will not physically move the file on disk, what the OP asks for.
Remus Rusanu
+1  A: 

You can do so with the ALTER DATABASE command, but you still have to move the file manually. The ALTER commands look like this:

ALTER DATABASE YourDb SET OFFLINE;

ALTER DATABASE YourDb
MODIFY FILE (Name = YourDb_Log,
    Filename = 'g:\NewDir\YourDb.ldf')

<At this point, move the file in the filesystem>

ALTER DATABASE YourDb SET ONLINE;

RECONFIGURE

See this SqlServer Central article for more information, and a complete script to execute the move.

Andomar
Nick Kavadias
@Nick Kavadias: Good point, updated the answer
Andomar