Posted By

DaveChild on 09/11/08


Tagged

database backup shrink logs transaction


Versions (?)

SQL Shrink Transaction Log


 / Published in: SQL
 

  1. CREATE PROCEDURE Shrink_Transaction_Log AS
  2.  
  3. -- Build log file name
  4. declare @strLogFile AS varchar(100)
  5. SET @strLogFile = 'C:\Backups\SQL\Transaction Logs\'
  6. 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)
  7. set @strLogFile = @strLogFile + '.bak'
  8.  
  9. BACKUP LOG LiveDatabase TO DISK = @strLogFile
  10.  
  11. -- Reduce log file to acceptable size
  12. DBCC SHRINKFILE(LiveDatabase_Log, 100)
  13.  
  14. GO

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: DaveChild on September 11, 2008

Hmm, seems the code colouring doesn't work quite right with SQL's take on escape characters.

You need to login to post a comment.