Truncating the Transaction Log
The size of a transaction log is controlled in one of these ways:
When a log backup sequence is being maintained, schedule BACKUP
LOG statements to occur at intervals that will keep the transaction log
from growing past the desired size.
This example creates a transaction log backup for the OEModels
database to the previously created named backup device,
OEModels_log1:
BACKUP LOG OEModels
TO OEModels_log1
GO
When a log backup sequence is not maintained, specify the simple
recovery model.
Truncation does not reduce the size of a physical log file, it reduces the size of
the logical log file.
Shrinking the Transaction Log
Shrinking a log is dependent on first truncating the log. Log truncation does not
reduce the size of a physical log file, it reduces the size of the logical log and
marks as inactive the virtual logs that do not hold any part of the logical log. A log
shrink operation removes enough inactive virtual logs to reduce the log file to the
requested size.
USE OEModels
GO
DBCC SHRINKFILE (OEModels_log, 7)
GO
This example shrinks the size of a logfile named OEModels_log in the
OEModels database to 7 MB.