Shrink a SQL Server Log File Without a Backup
In this article
Yes, you can shrink a SQL Server transaction log without taking a log backup: switch the database to the SIMPLE recovery model, checkpoint the log, then run DBCC SHRINKFILE on the log file. The catch is that this breaks your log backup chain, so it is a one-off cleanup, not a routine.
Time 5 min · Steps 5 · Level Medium
Shrink the Log in Five Steps
The log file only shrinks when the active portion of the log is small, and in FULL recovery that active portion stretches back to your last log backup. SIMPLE recovery lets the log clear itself automatically at checkpoints, which is what makes a shrink possible without a backup. Run the steps below in a query window connected to the right database.
- Check the recovery model. Run
SELECT name, recovery_model_desc FROM sys.databases WHERE name = 'YourDB';to see whether you are in FULL or SIMPLE already. - Switch to SIMPLE. Run
ALTER DATABASE YourDB SET RECOVERY SIMPLE;This tells SQL Server it may reuse log space as soon as transactions commit. - Force a checkpoint. Run
USE YourDB; CHECKPOINT;so the log clears immediately rather than waiting for the automatic checkpoint. - Find the log file name. Run
SELECT name, size/128 AS SizeMB FROM sys.master_files WHERE database_id = DB_ID('YourDB') AND type_desc = 'LOG';and note the logical name, which is often something like YourDB_log. - Shrink the file. Run
DBCC SHRINKFILE (YourDB_log, 256);where 256 is the target size in MB. Pick a size that leaves headroom for normal daily activity, not the bare minimum.
The Misconception: Shrink Frees Space for Nothing
Many people believe a huge log file means something is wrong and that shrinking fixes it. The correct fact is that a large log is usually the healthy result of FULL recovery plus log backups, or of a long-running transaction holding the log open. Shrinking without addressing the cause just means the file grows again, and every regrowth is an instant of paused writes while SQL Server zero-initialises the new space. If the log grew because a one-off bulk load or an index rebuild ran in FULL recovery, a single shrink after the event is reasonable. If it grows back within days, the shrink is treating a symptom.
What Breaking the Backup Chain Means
Switching to SIMPLE truncates the log, and in FULL recovery that invalidates your existing log backup sequence. Point-in-time restore to any moment after the switch is no longer possible until you take a full or differential backup and then resume log backups. If the database matters, take a full backup right after the shrink, and if you still need point-in-time recovery, switch back with ALTER DATABASE YourDB SET RECOVERY FULL; then take a new log backup to restart the chain. If the database is a dev or test copy where you never take log backups anyway, SIMPLE is the honest long-term home for it, and no chain is lost.
A Rule of Thumb for Target Size
Shrink to roughly the size the log reaches during a normal day plus about 25 percent headroom, then leave it alone. You can watch actual usage with DBCC SQLPERF(LOGSPACE); which lists every database's log size and the percentage in use. A log sitting at 90 percent used is not too small; it is doing its job. A log at 5 percent used and 100 GB on disk is a candidate for a one-time shrink. Also set a sensible autogrowth increment, in MB rather than the default 10 percent, so any future growth happens in controlled steps instead of repeated small extensions.
When the Shrink Barely Shrinks
If DBCC SHRINKFILE returns quickly and the file is still huge, something is holding the active log. Check for a long-running transaction with DBCC OPENTRAN; in the database, and look for database mirroring, log shipping or replication waiting on the log, because those features pin the log until they catch up. A stuck log mark or an old backup still running shows up the same way. Resolve the holder, checkpoint again, and rerun the shrink. In rare cases only one small virtual file at the end of the physical file is free, and the shrink moves a little at a time; running it a few times after checkpoints gets there eventually. Never shrink to 1 MB and hope for the best: the next heavy query will force a regrowth at the worst possible moment.
Keeping the Log Small Without Shrinking
The sustainable fix is more frequent log backups, not shrinking. In FULL recovery, a log backup every 15 minutes during working hours keeps the log at a steady, modest size and gives you point-in-time restore as a bonus. If you do not need that granularity, stay in SIMPLE and accept that the log will size itself to your largest single operation, such as a big index rebuild. Either way, shrink once to reclaim the disk, then let the file settle. Treating DBCC SHRINKFILE as a scheduled maintenance task is the one habit that reliably makes log-file problems worse, because the grow-shrink-grow cycle wastes disk work and fragments the log.
Official source: Microsoft Support