Growing Transaction Log Programatically

  • Can I grow the transaction Log using a script?

    My scenario:

    I have 3 different scripts that need to run on this particular database, 2 of them only need 4gb of TL space, so I set the transaction log to automatically grow by 4096, which works well, but the other script requires 24Gb, and it spends a lot of time growing the file while executing the script. I want to be able to grow the file to 24Gb before the script executes and then shrink it afterwards.

    Thank you,

    Ryk

  • This was removed by the editor as SPAM

  • My best guess (but not tested):

    -- Before batch

    use master

    go

    alter database foo_db

    modify file (name=foo_db_log,

    size=24 GB)

    go

    -- After batch

    use foo_db

    go

    dbcc shrinkfile (foo_db_log, 4000) -- Shrinking to 4 GB

    go

  • Thank you, yes that is what I ended up using.

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

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