SQL To Check Space Taken Up By Each Table

This SQL for use with Microsoft SQL Server is a little better than the standard EXEC sp_MSforeachtable @command1=”EXEC sp_spaceused ‘?’” SELECT t.NAME AS TableName, (sum(a.total_pages) * 8) / 1024 as TotalSpaceMB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id 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 …