建立数据库统计表,生成数据库中所有表名及表中的记录数


create table ##tableCount(
 tableName varchar(500),
 colCount int)
exec sp_msforeachtable 'insert into ##tableCount (tableName,colCount) select ''?'' tableName, count(*) colCount from ?'
select * from ##tableCount order by colCount



相关文章: