create table tmp( name varchar(50), rowscount int, reserved varchar(50), data varchar(50), index_size varchar(50), unused varchar(50)); insert tmp(name, rowscount, reserved, data, index_size, unused) exec sp_MSforeachtable @command1="sp_spaceused '?'";select * from tmp where name <> 'tmp' order by namedrop table tmp ;
另外一种方法
SELECT DISTINCT a.name ,b.rowsFROM sysobjects a ,sysindexes bWHERE a.id = b.idAND a.type = 'u' AND b.rows>0ORDER BY b.rows DESC