exec sp_MSForEachTable  

@precommand=N'

create table table_space(

id int identity,

表名 varchar(30),

字段数 int,

记录数 int,

保留空间 Nvarchar(10),

使用空间 varchar(10),

索引使用空间 varchar(10),

未用空间 varchar(10))',

@command1=N'insert table_space(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_spaceused ''?''

   update  table_space set 字段数=(select count(*) from syscolumns where id=object_id(''?'')) where id=scope_identity()',

@postcommand=N'select * from table_space  order by id    drop table table_space'