Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - shrink database log file

I am trying to shrink my database log file. I have tried to run:

USE databasename 
BACKUP log databasename
WITH truncate_only 
DBCC shrinkfile (databasename_log, 1)

I get the error message:

Msg 155, Level 15, State 1, Line 3 'truncate_only' is not a recognized BACKUP option.

Am I missing something?

like image 424
user258133 Avatar asked Apr 09 '26 14:04

user258133


1 Answers

SQL Server 2008 no longer allows the NO_LOG / TRUNCATE_ONLY options.

To truncate your transaction log, you either have to back it up (for real) or switch the database's Recovery Model to Simple. The latter is probably what you really want here. You don't need Full recovery unless you are making regular transaction log backups to be able to restore to some point mid-day.

like image 168
Aaronaught Avatar answered Apr 12 '26 16:04

Aaronaught



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!