CREATE TABLE #t
(
NAME VARCHAR(60),
row INT,
reserved VARCHAR(20),
DATA VARCHAR(20),
index_size VARCHAR(20),
unused VARCHAR(20)
)
INSERT INTO #t
EXEC sp_MSforeachtable 'exec sp_spaceused ''?'''
SELECT NAME,
row,
[reserved] = CAST(REPLACE(reserved, 'KB', '') AS INT),
[DATA] = CAST(REPLACE(DATA, 'KB', '') AS INT),
[index_size] = CAST(REPLACE(index_size, 'KB', '') AS INT),
[unused] = CAST(REPLACE(unused, 'KB', '') AS INT)
INTO #result
FROM #t
SELECT *
FROM #result
ORDER BY
DATA DESC