使用了微软提供的不公开的存储过程sp_msforeachtable
create table #temp ( tablename nvarchar (128), rowscnt varchar (11), reservedspace varchar(18), dataspace varchar(18), combinedindexspace varchar(18), unusedspace varchar(18) ) exec sp_msforeachtable'insert into #temp (tablename, rowscnt, reservedspace,dataspace, combinedindexspace, unusedspace) exec sp_spaceused ''?'', false' select tablename, rowscnt,reservedspace, dataspace, combinedindexspace, unusedspace from #temp order by tablename drop table #temp