/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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