--Script #2 : sp_MSForEachTable system stored procedure
--Creates a temporary table to hold the resultsets --returned by sp_spaceused and before calling it, --it updates the statistics for each table --Filter out tables of HumanResources schema only EXECUTE sp_MSforeachtable @precommand = 'CREATE TABLE ##Results ( name nvarchar(128), rows char(11), reserved varchar(50), data varchar(50), index_size varchar(50), unused varchar(50) )', @command1 = 'UPDATE STATISTICS ?;', @command2 = 'INSERT INTO ##Results EXECUTE sp_spaceused [?];', @whereand = 'and schema_name(schema_id) = ''dbo''', @postcommand = 'SELECT * FROM ##Results; DROP TABLE ##Results'