11 Oct 2010 @ 2:00 PM 

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.

image_6058D5EB

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.

select 
      sum(reserved_page_count) * 8.0 / 1024 as ''Database Size''
from 
      sys.dm_db_partition_stats 

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

image_6566226C

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 
      sys.objects.name as ''TableName'', sum(reserved_page_count) * 8.0 / 1024 as ''Size (in MB)''
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

 
Running those script on the management studio will result:
image_1D2840C3

References

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

Hope this helps.

Posted By: admin
Last Edit: 17 Oct 2012 @ 07:03 AM

EmailPermalink
Tags
Categories: SQL Azure


 

Responses to this post » (None)

 
Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


 Last 50 Posts
 Back
Change Theme...
  • Users » 123
  • Posts/Pages » 73
  • Comments » 86
Change Theme...
  • VoidVoid
  • LifeLife
  • EarthEarth
  • WindWind « Default
  • WaterWater
  • FireFire
  • LightLight

About Me



    No Child Pages.