Table Sizes in SQL Server – options
= 2 THEN a.used_pages ELSE 0 END) * 8 AS IndexSpaceKBFROM sys.tables tINNER JOIN sys.partitions p ON t.object_id = p.object_idINNER JOIN sys.allocation_units a ON p.partition_id = a.container_idGROUP BY t.nameORDER BY TotalSpaceKB DESC; What the Query Does This query calculates: TotalSpaceKB: The total space allocated for each table, including data, indexes, and unused space. UsedSpaceKB: The space actively used by data and indexes. UnusedSpaceKB: The difference between the allocated space and the used space, representing room for growth. DataSpaceKB: The size …