日期:2014-05-19  浏览次数:20470 次

几个表,可以用一条sql语句查询出这几个表中各个表的记录总数吗?
几个表,可以用一条sql语句查询出这几个表中各个表的记录总数吗?

------解决方案--------------------
select sum(a)
from (select count(*)as num from a
union all
select count(*)as num from b
union all
select count(*)as num from c
..........)ta
select (select count(*)as num from a)+(select count(*)as num from b)
------解决方案--------------------
select rowcnt from sysindexes where indid <2 and id=object_id( 'a ') union all
select rowcnt from sysindexes where indid <2 and id=object_id( 'b ') union all
select rowcnt from sysindexes where indid <2 and id=object_id( 'c ')