How can I get the table size using more than a method

Anonymous
2023-10-04T15:10:50.3933333+00:00

How to retrieve the space used by a table in SQL Azure? Are there many methods ?

Azure SQL Database
0 comments No comments
{count} votes

Accepted answer
  1. Amira Bedhiafi 33,071 Reputation points Volunteer Moderator
    2023-10-04T15:28:12.3+00:00

    You can go for a SQL query like the detailed one mentioned in [this blog] :

    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
    
    

    Or using the Azure Portal : https://techcommunity.microsoft.com/t5/azure-database-support-blog/how-to-get-azure-sql-database-size/ba-p/369189)

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. RahulRandive 10,486 Reputation points Volunteer Moderator
    2023-10-04T15:23:06.03+00:00

    Hi @Anonymous

    Please find the query below to get the size of each table in a given database.

    select obj.name, sum(reserved_page_count) * 8.0 as "size in KB" from sys.dm_db_partition_stats part, sys.objects obj where part.object_id = obj.object_id group by obj.name

    Thank you!

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.