如果是有关联的话,你可以这样写:select a.col1,a.col2,....,b.col1,b.col2 from table1 as a,table2 as b into [server2]..table3 where a.colp=b.colp
其中select 中的字段顺序可打乱,只要符合table3的要求
insert into [data1].dbo.model_table (id,intro,zheng,tech,rel,e_url,mu_id,mu_url,msg_id,msg_name,msg_cont,msg_time)
----------------------
select m_id,intro,zheng,tech,rel,e_url from [data2].dbo.model_table union (select mu_id,mu_url from [data2].dbo.my_upload union (select msg_id,msg_name,msg_cont,msg_time from [data2].dbo.my_msg))
后面的union语句错掉了
Eg:
select m_id,intro,zheng,tech,rel,e_url from [data2].dbo.model_table_1
union all
select m_id,intro,zheng,tech,rel,e_url from [data2].dbo.model_table_2
union all
select m_id,intro,zheng,tech,rel,e_url from [data2].dbo.model_table_3
union all 不去处重复行 union则去处
如果是把几张表的所有列拼接起来 可以这样得到
select identity(int,1,1) id,* into #tem1 from tab1
select identity(int,1,1) id,* into #tem2 from tab2
select identity(int,1,1) id,* into #tem3 from tab3
select [字段列表] from #tem1,#tem2,#tem3 where #tem1.id = #tem2.id and
#tem1.id = #tem3.id
字段列表 = 表名.字段名,...
insert into [data1].dbo.model_table (id,intro,zheng,tech,rel,e_url,mu_id,mu_url,msg_id,msg_name,msg_cont,msg_time)
select m_id,intro,zheng,tech,rel,e_url from [data2].dbo.model_table union (select mu_id,mu_url from [data2].dbo.my_upload union (select msg_id,msg_name,msg_cont,msg_time from [data2].dbo.my_msg))