Friday, March 13, 2009

SQL Server 2005: Shrink and Truncate Log file size

USE
GO
DBCC SHRINKFILE(<Logical Name of Transaction Log>, 1)
BACKUP<Database Name> LOG WITH TRUNCATE_ONLY

1 (second parameter of DBCC SHRINKFILE) is target size of file in megabytes.

It won’t take backup of log file. Hence log will be lost. Make sure to take backup if you really want log.

1 comment:

  1. More info:
    http://www.beyondweblogs.com/post/SQL-Server-2005-Shrink-and-Truncate-Log-file-size.aspx

    ReplyDelete