For example: exec sp_MSForEachTable @precommand=N'create table temp(name sysname,rows bigint,reserved Nvarchar(100),data varchar(100),index_size varchar(100),unused varchar(100))',@command1=N'insert temp exec sp_spaceused ''?''',@postcommand=N'select