获取表的总记录数

set nocount on
if object_id(N'tempdb.db.#temp') is not null
drop table #temp
create table #temp (name sysname,count numeric(18))
insert into #temp
select o.name,i.rows
from sysobjects o,sysindexes i  
where o.id=i.id and o.Xtype='U' and i.indid<2
--select count(count) 总表数,sum(count) 总记录数 from #temp
select * from #temp order by name
set nocount off


 

 

select a.name '名称',  
	a.xtype '类型', 
	b.rowcnt '行数', 
	b.reserved*8 '字节数(KB)', 
	a.crdate '创建日期',
	a.refdate '最新修改日期' 
from sysobjects a  
inner join sysindexes b on a.id=b.id  
where a.xtype in('U','S') and b.indid<=1


 

你可能感兴趣的:(获取表的总记录数)