-- Table row counts and sizes.
CREATE TABLE #t
(
[name] NVARCHAR(128),
[rows] CHAR(11),
reserved VARCHAR(18),
data VARCHAR(18),
index_size VARCHAR(18),
unused VARCHAR(18)
)
INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?'''
UPDATE #t SET reserved = REPLACE(REPLACE(reserved, 'kb', '') , ' ', '')
UPDATE #t SET data = REPLACE(REPLACE(data, 'kb', '') , ' ', '')
UPDATE #t SET index_size = REPLACE(REPLACE(index_size, 'kb', '') , ' ', '')
UPDATE #t SET unused = REPLACE(REPLACE(unused, 'kb', '') , ' ', '')
SELECT *
FROM #t
order by cast (data as int ) desc
SELECT *
FROM #t
order by cast (reserved as int ) desc
-- # of rows.
SELECT SUM(CAST([rows] AS int)) AS [rows]
FROM #t
-- DROP TABLE #t
Wednesday, January 12, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment