Return to Snippet

Revision: 8285
at September 11, 2008 10:38 by DaveChild


Initial Code
CREATE PROCEDURE Shrink_Transaction_Log AS

    -- Build log file name
    declare @strLogFile as varchar(100)
    set @strLogFile = 'C:\Backups\SQL\Transaction Logs\'
    set @strLogFile = @strLogFile + cast(year(getdate()) as varchar(4)) + ' - ' + right('00' + cast(month(getdate()) as varchar(2)), 2)  + ' - ' + right('00' + cast(day(getdate()) as varchar(2)) , 2)
    set @strLogFile = @strLogFile + '.bak'

    BACKUP LOG LiveDatabase TO DISK = @strLogFile

    -- Reduce log file to acceptable size
    DBCC SHRINKFILE(LiveDatabase_Log, 100)

GO

Initial URL

                                

Initial Description

                                

Initial Title
SQL Shrink Transaction Log

Initial Tags
database, backup

Initial Language
SQL