Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to BACKUP LOG WITH TRUNCATE_ONLY

This piece of T-SQL is deprecated in 2005:

BACKUP LOG [DB_NAME] WITH TRUNCATE_ONLY

I don't need to keep a backup the log for my db - but I do not want the piece of code to stop working if we port to SQL2008 or successive versions in future.

Cheers

like image 443
JohnIdol Avatar asked Mar 01 '23 05:03

JohnIdol


1 Answers

Switch the database recovery mode to SIMPLE, and then use DBCC SHRINKFILE. Then restore your original recovery mode. If your LOG file does not shrink, you might have uncommitted transactions. For more details, see Tibor's Karaszi's article on shrinking.

like image 160
Mitch Wheat Avatar answered Mar 07 '23 21:03

Mitch Wheat