开发者

How do I move the Transaction Log for a database using sqlcmd/command line?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜