博客园  :: 联系 :: 管理

统计数据表记录数

Posted on 2006-07-24 19:14  独孤雁  阅读(313)  评论(0编辑  收藏  举报

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


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