select * from t1 union all select * from t2 union all select * from t3 ...
select * into 中间表 from ( select * from t1 union all select * from t2 union all select * from t3 union all select * from t4 union all select * from t5 union all select * from t6 union all select * from t7 ) t
create view TotalTable asselect * from t1 union all select * from t2 union all select * from t3 union all select * from t4 union all select * from t5 union all select * from t6 union all select * from t7 GO 这七个表的结构必须一致。以后就直接访问视图TotalTable 就可以了
如果要把表插入到另外的一个数据表,则 insert into 中间表 select * from t1 union all select * from t2 union all select * from t3 union all select * from t4 union all select * from t5 union all select * from t6 union all select * from t7
为什么不 insert into 中间表 select * from t1 where 时间in七天内?
union all
select * from t2
union all
select * from t3
...
(
select * from t1
union all
select * from t2
union all
select * from t3
union all
select * from t4
union all
select * from t5
union all
select * from t6
union all
select * from t7
) t
asselect * from t1
union all
select * from t2
union all
select * from t3
union all
select * from t4
union all
select * from t5
union all
select * from t6
union all
select * from t7 GO
这七个表的结构必须一致。以后就直接访问视图TotalTable
就可以了
insert into 中间表
select * from t1
union all
select * from t2
union all
select * from t3
union all
select * from t4
union all
select * from t5
union all
select * from t6
union all
select * from t7
insert into 中间表
select * from t1 where 时间in七天内?