Trying to move log file

  • Hi!

    1. Create the second log file

    USE master

    GO

    ALTER DATABASE My_DB

    ADD LOG FILE

    ( NAME = My_DB_log2,

    FILENAME = 'D:\SQLlog\My_DB_log2.ldf',

    SIZE = 5MB,

    FILEGROWTH = 5MB)

    GO

    2. Back up the database and clear the log

    3. Trying to delete the first log file:

    USE master

    GO

    ALTER DATABASE My_DB

    REMOVE FILE My_DB_log

    GO

    ------------------------------

    And get:

    Server: Msg 5020, Level 16, State 1, Line 1

    The primary data or log file cannot be removed from a database.

    Is it possible to make the second log file as primary and the first as none primary, so to be able to delete it?

  • Why do you want to make second log file as primary? What do you want to achieve?

  • Currently I have both data and logs on the same disk array(Raid5), I just want to create another log file on a newly installed mirror and delete the first log file. The database has a lot of replication, so detach/attach, backup/restore will destrpy all replications

    I want to make the second file primary, so I can delete the first.

  • One work around is to empty the primary log file and restrict the automatically grow file so any transaction logs will be logged in the second log file.

    No ideas how can the primary file be removed without detach/attach.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply