1 SELECT 2 TableName = obj.name, 3 TotalRows = prt.rows, 4 [SpaceUsed(KB)] = SUM(alloc.used_pages)*8 5 FROM sys.objects obj 6 JOIN sys.indexes idx on obj.object_id = idx.object_id 7 JOIN sys.partitions prt on obj.object_id = prt.object_id 8 JOIN sys.allocation_units alloc on alloc.container_id = prt.partition_id 9 WHERE 10 obj.type = 'U' AND idx.index_id IN (0, 1) 11 GROUP BY obj.name, prt.rows 12 ORDER BY TotalRows DESC