SQL Server Azure – What is my current database size?

If you are hosting on Microsoft Windows Cloud (Azure), you know that the two type of databases that you can allocate are restricted to 1GB and respectively 5GB to the personal edition and 150GB for the business edition.

If you wish to know how much space you have used so far, use the following query to return the database size:

select
sum(reserved_page_count) * 8.0 / 1024 asDatabaseSizeMB
from
sys.dm_db_partition_stats
GO

The result will be shown in MB as in the picture below:

Capture

If you wish to know which tables in your database are responsible for this database size, you can run the following query that will show the table size from largest to smallest. System tables are also included. The size is displayed in MB.

select
sys.objects.name, sum(reserved_page_count) * 8.0 / 1024
from
sys.dm_db_partition_stats, sys.objects
where
sys.dm_db_partition_stats.object_id = sys.objects.object_id

group by sys.objects.name
ORDER BY 2 DESC

Capture.JPG

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s