搜索一下链接服务器.的用法. 然后insert into linkserver.database.dbo.表 select * from 表
insert into talbeA (id,name) select id,name from tableB
两个SQL在两台电脑上,也就是说 是两个SQL服务
INSERT INTO [databasename].[dbo].[buffer_trade]seller_nick,buyer_nick,seller_title,created,type,parent_tid) (select t.seller_nick,t.buyer_nick,t.title as seller_title,t.created,t.type,t.tid as parent_tidfrom [databasename].[dbo].[table] as o left join [databasename].[dbo].[table] as t on o.parent_tid=t.tid )
以上代码是从一个databasename里获取相应信息,插入到别外一个databasename里,
搞不定啊 再简单点吧。。我查询出的结果 能通过sqlserver 转换成INSERT 语句吗?
selelct * into yourtable from table1 a left join table2 b on a.id=b.id and 其它条件
2.SELECT INTO FROM语句 语句形式为:SELECT vale1, value2 into Table2 from Table1 要求目标表Table2不存在,因为在插入时会自动创建表Table2,并将Table1中指定字段数据复制到Table2中。 1.INSERT INTO SELECT语句 语句形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Table1 要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量
然后insert into linkserver.database.dbo.表 select * from 表
(select t.seller_nick,t.buyer_nick,t.title as seller_title,t.created,t.type,t.tid as parent_tidfrom [databasename].[dbo].[table] as o left join [databasename].[dbo].[table] as t on o.parent_tid=t.tid )
1.INSERT INTO SELECT语句 语句形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Table1 要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量