SQL Server 2008 - Shrinking the Transaction Log - Any way to automate?

后端 未结 6 509
醉酒成梦
醉酒成梦 2021-02-03 14:30

I went in and checked my Transaction log the other day and it was something crazy like 15GB. I ran the following code:

USE mydb
GO
BACKUP LOG mydb WITH TRUNCATE         


        
6条回答
  •  梦如初夏
    2021-02-03 15:28

    for SQL Server 2005

    DBCC SHRINKFILE ( Database_log_file_name , NOTRUNCATE)

    This statement don't break log shipping. But, you may need to run more than one. For each run, the log shipping backup, copy, and restored to run after again run this statement.

    Shrink and truncate are different.

    My experiences:

    AA db, 6.8GB transaction log
    first run: 6.8 GB
    log shipping backup, copy, restore after second run: 1.9 GB
    log shipping backup, copy, restore after third run: 1.7 GB
    log shipping backup, copy, restore after fourth run: 1 GB

    BB db, 50GB transaction log
    first run: 39 GB
    log shipping backup, copy, restore after second run: 1 GB

提交回复
热议问题