This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

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.

  • 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