–This will give you the amount of disk space that each table uses in a database.
SET NOCOUNT ON
DECLARE @cmdstr varchar(100)
DECLARE @Sort bit
CREATE TABLE #TempTable
( [Table_Name] varchar(50),
Row_Count int,
Table_Size varchar(50),
Data_Space_Used varchar(50),
Index_Space_Used varchar(50),
Unused_Space varchar(50)
)
SELECT @cmdstr = 'sp_msforeachtable ''sp_spaceused "?"'''
INSERT INTO #TempTable EXEC(@cmdstr)
–Use one of these depending what you are looking for.
–SELECT * FROM #TempTable ORDER BY Table_Name
SELECT * FROM [...]
