Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (45.3k points)

In mssql2005 when I want to get the size of a table in MBs, I use EXEC sp_spaceused 'table'.

Is there any way to get space used by a particular table in SQL Azure using some query or API?

1 Answer

0 votes
by (16.8k points)

Refer this blog :http://dunnry.com/blog/CalculatingTheSizeOfYourSQLAzureDatabase.aspx

select    

      sum(reserved_page_count) * 8.0 / 1024 [SizeInMB]

from    

      sys.dm_db_partition_stats

GO

select    

      sys.objects.name, sum(reserved_page_count) * 8.0 / 1024 [SizeInMB]

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 sum(reserved_page_count) DESC

At first, you will get the size of your database in MB and the second one will do the same, just break them out for each of the object in your Database ordered from largest to smallest.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...