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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With