A SQL Server transaction log can retain allocated disk space after an unusually large operation. A one-off shrink may reclaim unused space, but the log needs enough capacity for normal work and recovery.

Check whether shrinking is appropriate

This procedure concerns the transaction log, not an exported .sql script or the database’s data files. Take a suitable backup and confirm the recovery and log-backup requirements with the database administrator.

In a query window for the intended database, inspect its logical files:

SELECT name, type_desc, size / 128.0 AS size_mb
FROM sys.database_files;
SELECT name, recovery_model_desc, log_reuse_wait_desc
FROM sys.databases
WHERE database_id = DB_ID();

Investigate anything preventing log reuse, such as an open transaction or a required log backup. Under Full recovery, use the established transaction-log backup process rather than changing recovery models just to shrink a file.

Shrink a confirmed log file

  1. In SQL Server Management Studio, right-click the database and select Tasks > Shrink > Files.
  2. Choose Log as the file type and select the intended logical log file.
  3. Choose a target size based on the workload, leaving capacity for normal transactions.
  4. Confirm the operation and review the result.

The target is not guaranteed if active log records prevent space being released. Check log growth and backup scheduling afterwards. Repeated shrink-and-grow cycles indicate that the space is needed or that the underlying problem remains unresolved.