连接! eg: create table A ( id int )create table B ( id int, name varchar(10) )insert A select 1insert B select 1,'Test' select A.id,B.name from A ,B where A.id=B.id
哦!看错咯! select count(*) from A,B where 连接的关系...
select count(*) as acount ,(select count(*) from b )as bcount,(select count(*) from c) as ccount,... from a
use 数据库的名字 exec sp_Msforeachatable @command1='select tablename=''?'',Records=count(*) from ?', @whereand='and o.name like ''%pub%''', @precommand='Print ''Procedd Begin''', @postcommand='Print ''process End'''
exec sp_Msforeachtable @command1='select tablename=''?'',Records=count(*) from ?', @whereand='and o.name like ''%s%''', ----s为数据库中表所包含的字段,例如 表 --------------------------------------------------students 含有s字符 @precommand='Print ''Procedd Begin''', @postcommand='Print ''process End'''
第一步 create view Vcount as select 'tablename1' as '表名',count(*) as '记录数' from tablename1 union all select 'tablename2' as '表名',count(*) as '记录数' from tablename2第二步 select * from Vcount
eg:
create table A
(
id int
)create table B
(
id int,
name varchar(10)
)insert A select 1insert B select 1,'Test'
select A.id,B.name from A ,B where A.id=B.id
select count(*) from A,B where 连接的关系...
from a
exec sp_Msforeachatable
@command1='select tablename=''?'',Records=count(*) from ?',
@whereand='and o.name like ''%pub%''',
@precommand='Print ''Procedd Begin''',
@postcommand='Print ''process End'''
@command1='select tablename=''?'',Records=count(*) from ?',
@whereand='and o.name like ''%s%''', ----s为数据库中表所包含的字段,例如 表 --------------------------------------------------students 含有s字符
@precommand='Print ''Procedd Begin''',
@postcommand='Print ''process End'''
create view Vcount
as
select 'tablename1' as '表名',count(*) as '记录数' from tablename1
union all
select 'tablename2' as '表名',count(*) as '记录数' from tablename2第二步
select * from Vcount