Search code examples
sql-serversql-server-2005sql-server-2000

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


Solution

  • 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.