atitit.mssql 数据库表记录数and 表体积大小统计 1. exec sp_msforeachtable execute sp_spaceused ? 最后一种方法是利用隐藏未公开的系统存储过程sp_msforeachtable create table #temp (tablename varchar (255), rowcnt int) exec sp_msforeachtable inse
atitit.mssql 数据库表记录数and 表体积大小统计
1. exec sp_msforeachtable execute sp_spaceused '?'最后一种方法是利用隐藏未公开的系统存储过程sp_msforeachtable
create table #temp (tablename varchar (255), rowcnt int)
exec sp_msforeachtable 'insert into #temp select ''?'', count(*) from ?'
select tablename, rowcnt from #temp order by tablename
drop table #temp
从mssql6.5开始,微软提供了两个不公开,非常有用的系统存储过程sp_msforeachtable和sp_msforeachdb,用于遍历某个数据库的每个表和遍历dbms管理下的每个数据库。
作者:: 老哇的爪子 attilax 艾龙, email:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
2. 查询首先通过sysobjects表3. 参考sqlserver中统计所有表的记录数 - minisunny的专栏 - 博客频道 - csdn.net.htm