Script: Transaction Log Size and Usage by Database

This script returns transaction log size and usage information for all databases on the instance. It shows total log size, used log space, percentage used, and recovery model.

This is commonly used during log growth incidents, backup troubleshooting, or when validating log management across an environment.


The Script


Example Output

The result set shows one row per database, including recovery model, total log size in MB, used log space in MB, and percentage used.

Databases with the highest log usage percentage appear first, making it easy to identify potential log growth risks.

SQL Server query showing transaction log size and usage per database

Notes

  • High usage percentage may indicate missing log backups in FULL recovery model
  • SIMPLE recovery databases will not require log backups
  • Persistent high usage may indicate long-running transactions
  • Useful before investigating log growth or autogrowth events

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *