Get the size of a SQL Azure database quickly

2018-04-06 | Toni Pohl

To get the size of a database, there are multiple ways. TSQL is one of the fastest methods. Here’s how.

You often see querying the sys.dm_db_partition_stats DMV, and looking at the reserved_page_count column. Here’s my slightly adapted query: First open a new query in the database you want to check, then execute the following statement to get the size in Gigabytes.

SELECT (SUM(reserved_page_count) * 8192) / 1024 / 1024 / 1024.0 AS DbSizeInGB
FROM sys.dm_db_partition_stats


Kindly, this is the same number, the Azure portal delivers, here the database size is (rounded) 6.06 GB. Additionally, the database overview menu informs about more interesting database properties and statistics.


See more at Monitoring Azure SQL Database using dynamic management views (find more useful queries there as well) and at Determining Database Size in Azure SQL Database V12.

Just to mention: The database size is not the same as for backups. When exporting the Data-tier to a .bacpac file, the database backup is just about 265 MB. Well packed!


(Another database with a database size of 0.10GB exported a 6.3MB small .bacpac file...)

So, the TSQL select does a good job for a quick database size overview.

Categories: Azure, Cloud, Developer, English, Microsoft, SQL Server