In Microsoft SQL server 2000 and 2005, as part of the ‘BACKUP LOG’ command, there was an option to truncate the log file, without storing a backup to file. In Microsoft SQL Server 2008, this option has been removed, and you can now no longer use the ‘TRUNCATE_ONLY’ option when performing a transaction log backup.
The truncate only option is used to truncate the log file. This is generally done so you can then shrink the transaction log file, and recover the disk space back to the file system.
I ran into this issue, when we are migrating our servers from 2005 to higher version.
Msg 155, Level 15, State 1, Line 1 'TRUNCATE_ONLY' is not a recognized BACKUP option.
To truncate the transaction log file in Microsoft SQL Server 2008 or 2012 and above, without making an actual transaction log backup (possibly due to free space limitations), you need to change the recovery model of the database to “Simple”, and then change it back to “Full” (or “Bulked Logged” if that’s what it was previously).
USE ps; GO -- Truncate the log by changing the database recovery model to SIMPLE. ALTER DATABASE ps SET RECOVERY SIMPLE; GO -- Shrink the truncated log file to 1 MB. DBCC SHRINKFILE (ps_log, 1); -- here 2 is the file ID for trasaction log file --you can also mention the log file name (dbname_log) GO -- Reset the database recovery model. ALTER DATABASE ps SET RECOVERY FULL; GO
Hope this helps.
No comments:
Post a Comment