Calculating The Size of SQL Azure Database and Tables

If you want to see how much size has you used in your SQL Azure database, you can definitely see it on the SQL Azure Developer Portal as shown below.


However, for some reason, sometimes you would either need to get the size more precisely or retrieve the numbers programmatically.

Calculating Database Size

Here’s the query for you to retrieve the size of your database.

      sum(reserved_page_count) * 8.0 / 1024 as ''Database Size''

After running in on my SQL Server Management Studio R2, here’s the result:


Calculating Each Table in the Database

If you need to explore in more detail how much size for each table, you can also use the following query to see.

select as ''TableName'', sum(reserved_page_count) * 8.0 / 1024 as ''Size (in MB)''
      sys.dm_db_partition_stats, sys.objects 
      sys.dm_db_partition_stats.object_id = sys.objects.object_id
group by

Running those script on the management studio will result:


You may want to learn more about SQL Azure tips and tricks, be sure to check out the following posts:

Hope this helps.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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