Questo script visualizza l’elenco delle tabelle di un database visualizzando il relativo peso in megabyte:
DECLARE @t TABLE (
Name VARCHAR(128),
Rows INT,
Reserved VARCHAR(20),
Data VARCHAR(20),
Index_Size VARCHAR(20),
Unused VARCHAR(20)
)
INSERT INTO @t
EXEC sp_msForEachTable 'EXEC sp_SpaceUsed ''?'''
SELECT
@@servername AS 'ServerName',
Db_Name() AS 'DBName',
Name AS 'TableName',
Rows,
(REPLACE(Reserved, ' kb', ''))/1024 AS 'SizeMB'
FROM @t
ORDER BY SizeMB DESC