1 Reply Latest reply on Sep 12, 2017 8:09 AM by Petr Vilem

    Track SQL database table level size?

    russcollier

      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.

        • Re: Track SQL database table level size?
          Petr Vilem

          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