Results 1 to 5 of 5

Thread: [RESOLVED] Monsterous Transaction Log

  1. #1

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Resolved [RESOLVED] Monsterous Transaction Log

    All,

    we have a MSSQL DB that has a transaction log approaching a GB! How do I tame it? We researched the issue and it seems we need to create some kind of "restore point" on the database, but have been unable to determine how to do this.

    Any ideas? Will DBCC ShrinkDatabase do it? Remember, it is the transaction log that is out of control in size.

    Thanks!

    Dave
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  2. #2
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: Monsterous Transaction Log

    You should either backup the transaction log or truncate it with the TRUNCATE_ONLY option.

    Code:
    BACKUP LOG YouDbName [WITH TRUNCATE_ONLY]
    After you have truncated it, you can shrink the actual file by executing the DBCC SHRINKDATABASE statement, but as long as you have enough disk space I don't see a reason for shrinking the physical size.

  3. #3

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Monsterous Transaction Log

    Quote Originally Posted by kaffenils
    You should either backup the transaction log or truncate it with the TRUNCATE_ONLY option.

    Code:
    BACKUP LOG YouDbName [WITH TRUNCATE_ONLY]
    After you have truncated it, you can shrink the actual file by executing the DBCC SHRINKDATABASE statement, but as long as you have enough disk space I don't see a reason for shrinking the physical size.
    Great! I did all this and was able to shrink the T-log somewhat, but this code doesn't work:

    Code:
    BACKUP LOG YouDbName [WITH TRUNCATE_ONLY] TO MyDevice
    This code does work but am wondering how to use the truncate function:

    Code:
    BACKUP LOG YouDbName TO MyDevice
    Last edited by Dave Sell; Mar 14th, 2006 at 10:35 AM.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  4. #4

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Monsterous Transaction Log

    Looks like I got it now. I used:

    Code:
    BACKUP LOG MyDBName WITH TRUNCATE_ONLY
    Then,

    Code:
    DBCC SHRINKDATABASE (MyDBName)
    Works like a charm, thanks!
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  5. #5

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: [RESOLVED] Monsterous Transaction Log

    For anyone else interested, you can backup the T-Log to disk by making a device then backing up to it:

    Code:
    -- (1) Create the log backup device.
    /*
    USE myDBName
    EXEC sp_addumpdevice 'disk', 'myDBNameBackup',
       'c:\Temp\myDBName.dat'
    */
    Code:
    -- (2) Perform the backup - this option may only reduce the LOG file by 50%
    /*
    BACKUP LOG myDBName  
       TO myDBNameBackup
    */
    Code:
    -- (2) Alternative - this option brings the LOG file back down to 1 MB.
    /*
    BACKUP LOG myDBName WITH TRUNCATE_ONLY
    */
    Code:
    -- (3) Shrink or compact the database
    /*
    DBCC SHRINKDATABASE (myDBName)
    */
    Last edited by Dave Sell; Jul 10th, 2006 at 10:47 AM.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width