Select SQL Server database size
To swiftly get the size of your SQL Server database, use the following T-SQL query:
This T-SQL query calculates the sizes of all files linked to your current database (use DB_NAME()
without arguments for the active database) and turns the total from pages into megabytes (MB). It's a clear-cut, straightway method for accessing the size of an active database on your SQL Server.
Dig deeper for more details
More often than not, a detailed understanding of your database size can help solve or avoid issues.
Split database size into data and log
By dividing the size
based on type_desc
, you can get a granular look of the space consumed by data files and log files separately.
Size vs Free Space—Know the difference
This neat piece of code provides current size and free space for each file within the database—crucial info when you're planning for future storage needs.
A glimpse into database growth and backups
Here, you get a glimpse of your database's growth trends and backup history. This is valuable for capacity planning and for ensuring data is recoverable from backups.
Know more with built-in reports
Yes, even SQL Server Management Studio (SSMS) has its disk usage reports. It's great if you want a more visual way of knowing your database size.
- Right-click on your database in SSMS > Reports > Standard Reports > Disk Usage.
This method offers more in-depth understanding of your database - how its data and log files sizes change over time, and the free spaces they have.
Was this article helpful?