views:

2993

answers:

4

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

+2  A: 

If you change the recovery model of the database to Simple, I think it will stop forcing you to backup/truncate the log.

Greg
+4  A: 

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 uncommited transactions. For more details, see Tibor's Karaszi's article on shrinking.

Mitch Wheat
is there any other way of shrinking the log (without using the deprecated T-SQL above) without switching to simple mode?
JohnIdol
If you are not in simple mode, you should be backing up the log. Looking at BOL for 2008, it appears to me that this command was deprecated to force people to backup the log as the only method I found to truncate the log was to make a backup if you are not in simple mode.
HLGEM
is there any feature I'd lose if I switch to simple mode?
JohnIdol
+1  A: 

Change your database to use the simple recovery model. This means you do not have point in time recovery (you won't have that anyway if you are truncating your log), but the log file is automatically cycled and won't grow too large.

A log file is mandatory and you have no option but to keep it, what you don't want is for it to grow out of control and fill your disk.

Andy Jones
I meant I don't need to keep a backup of the log
JohnIdol
A: 

As Andy Jones answered, the log file is mandatory. It is not simply a log of events for your sake, but a vital part of the way the database handles transaction rollbacks as well as memory commits.

kasperjj
I meant I don't need to keep a backup of the log
JohnIdol