你是要查询所有表中满足这个条件的记录吗??
你看这样行不行,将表放到一个视图中,你查询直接访问视图。
Create View List
As
Select * from [aa-bb-cc001]
Union All
Select * from [aa-bb-cc001]
Union All
Select * from [aa-bb-cc002]
Union All
Select * from [aa-bb-cc003]
Union All
Select * from [aa-bb-cc004]
Union All
Select * from [aa-bb-cc005]
Union All
Select * from [aa-bb-cc006]
Union All
Select * from [aa-bb-cc007]
Union All
Select * from [aa-bb-cc008]
Union All
Select * from [aa-bb-cc009]
GO
Select count(1),sum(fee_code),fee_code from List
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
select count(1),sum(fee_code),fee_code from
[aa-bb-cc001]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc002]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc003]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc004]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc005]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc006]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc007]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc008]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
Union All
select count(1),sum(fee_code),fee_code from
[aa-bb-cc009]
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
select count(1),sum(fee_code),fee_code from aa-bb-cc001
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
union all
select count(1),sum(fee_code),fee_code from aa-bb-cc002
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
union all
select count(1),sum(fee_code),fee_code from aa-bb-cc003
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
union all
select count(1),sum(fee_code),fee_code from aa-bb-cc004
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
union all
select count(1),sum(fee_code),fee_code from aa-bb-cc005
where substring(mtid,5,3)='999' and respond_result=0
group by fee_code
...
以下一样