当前位置: 代码迷 >> Sql Server >> 怎么用SQL语句将数据库表合并
  详细解决方案

怎么用SQL语句将数据库表合并

热度:24   发布时间:2016-04-27 16:51:55.0
如何用SQL语句将数据库表合并?
有三个数据库表,字段名称大同小异
现在要将三个数据库表中的数据转移到新建的表中
这个新建的表中仅仅多个一个字段
用Sql语句怎么实现?

------解决方案--------------------
insert into newtable
select * from
(
select * from table1
union all
select * from table2
union all
select * from table3
)
a
------解决方案--------------------
select * into newtablename
from (
select col1 ,col2...coln from table1
union all
select col1 ,col2...coln from table2
union all
select col1 ,col2...coln from table3
)

  相关解决方案