Table Space Details

This script will list out the details of the space used by each in a database.This is compatible to SQL 2000 and 2005.

Script

CREATE TABLE #spacedetails (name VARCHAR(100),totrows BIGINT,reserved VARCHAR(30), 
DATA VARCHAR(30),index_size VARCHAR(30), unused VARCHAR(30))
INSERT INTO #spacedetails
EXEC sp_MSForeachtable @command1 = "sp_spaceused '?'" SELECT name,totrows, REPLACE(DATA,'KB','') AS 'Data in KB', 
REPLACE(Index_Size,'KB','') AS 'Index Size in KB' FROM #spacedetails
ORDER BY name
DROP TABLE #spacedetails 

Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *