SELECT OBJECT_NAME(i.object_id) AS objectName, i.name AS indexName, SUM(a.total_pages) AS totalPages, SUM(a.used_pages) AS usedPages, SUM(a.data_pages) AS dataPages, (SUM(a.total_pages) * 8) / 1024 AS totalSpaceMB, (SUM(a.used_pages) * 8) / 1024 AS usedSpaceMB, (SUM(a.data_pages) * 8) / 1024 AS dataSpaceMB 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 GROUP BY i.object_id, i.index_id, i.name ORDER BY SUM(a.total_pages) DESC, OBJECT_NAME(i.object_id);