exec sp_MSForEachTable
@precommand=N'
create table ##(
id int identity,
table name sysname,
number of fields int,
number of records int,
reserved Space Nvarchar(10),
used space varchar(10),
index used space varchar(10),
unused space varchar(10))',
@command1=N'insert # #(Table name, number of records, reserved space, used space, index used space, unused space) exec sp_spaceused ''?''
update ## set number of fields=(select count(*) from syscolumns where id= object_id(''?'')) where id=scope_identity()',
@postcommand=N'select * from ## order by id drop table ##'