Get All Database Sizes & Free Space Info In SQL Server

Monitoring database file sizes and free space within data and log files is an important part of monitoring SQL Server health. This information, along with other metrics such as growth events, can help you to better predict and plan for future disk space provisioning needs.

The following script provides a quick way to view database file size information. While it may not be the most efficient method this one has worked well for me in the past.

The query output shows each database on the instance along with its current size and available free space. Here’s an example of what the output may look like:

Free space in MS SQL database

Conclusion

This script provides a quick way to assess database sizes and available free space in SQL Server, helping you quickly check space database space.

It’s important to consider the impact of the recovery model, as log file free space can vary based on whether you’re using Simple, Full, or Bulk-logged. Autogrowth settings may also cause file sizes to increase in small increments, making it more important for you to track these growth patterns for future storage planning.

While shrinking database files is possible, it’s generally not recommended in production due to the risk of fragmentation and performance issues while running shrinks. Instead, proactively plan your storage needs.

Always test any script changes in a non-production environment before applying them to critical systems, for any random blog you read.


Comments

Leave a Reply

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