Query to truncate log files or shrink all MS SQL Databases

1 post / 0 new
#1 20 April, 2017 - 18:40
Divya
Divya's picture

Query to truncate log files or shrink all MS SQL Databases

Execute the following query to shrink and truncate log files of all the databases in the instance. For MS SQL version 2000 & 2005
  1. span style="color: #ff0000;">'0', '1','16''Recovery''SIMPLE''ALTER DATABASE' + ' ' <a href="mailto:+@DBName">+@DBName</a>+ ' ' + 'SET RECOVERY SIMPLE''BACKUP LOG' + ' ' <a href="mailto:+@DBName">+@DBName</a>+ ' ' + 'WITH NO_LOG''DBCC SHRINKDATABASE(' + '' <a href="mailto:+@DBName">+@DBName</a>+ '' + ', TRUNCATEONLY)''EXECUTING - ''EXECUTING - ''EXECUTING - ''ALTER DATABASE' + ' ' <a href="mailto:+@DBName">+@DBName</a>+ ' ' + 'SET RECOVERY ''EXECUTING - ''BACKUP LOG' + ' ' <a href="mailto:+@DBName">+@DBName</a>+ ' ' + 'WITH NO_LOG''DBCC SHRINKDATABASE(' + '' <a href="mailto:+@DBName">+@DBName</a>+ '' + ', TRUNCATEONLY)''EXECUTING - ''EXECUTING - '