cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 8

Track SQL database table level size?

Is there an out of the box way to view/track individual SQL database table sizes for a SQL database that's being monitored with "AppInsight for SQL". I've seen there are ways to view the current snapshot of "Top 10 Tables by Size" for a given database, and for the database-level data file and transaction file sizes. But is there a way to drilldown and view the historical size of an individual table?

Thanks in advance.

0 Kudos
1 Reply
Level 13

I believe that you could find some inspiration in this template: SQL Database Size

SQL query can be easily modified to watch just single selected table like this:

SELECT TOP 1

    SUM(CONVERT(BIGINT, a.total_pages)) * 8192 AS TableSize

FROM

    sys.indexes i

INNER JOIN

    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id

INNER JOIN

    sys.allocation_units a ON p.partition_id = a.container_id

WHERE i.object_id = OBJECT_ID('dbo.YourTable')

Petr

0 Kudos