SET b.Com_introduce = a.company_intro --这里改改
FROM australia.dbo.companytest as a, yimingong.dbo.company as b
WHERE
(a.id = 2 AND b.Com_Id = 1) OR
(a.id = 14 AND b.Com_Id = 2) OR
(a.id = 18 AND b.Com_Id = 3) OR
(a.id = 5 AND b.Com_Id = 4) OR
(a.id = 16 AND b.Com_Id = 5) OR
(a.id = 18 AND b.Com_Id = 6) OR
(a.id = 15 AND b.Com_Id = 7) OR
(a.id = 4 AND b.Com_Id = 8) OR
(a.id = 3 AND b.Com_Id = 9) OR
(a.id = 12 AND b.Com_Id = 10) OR
(a.id = 6 AND b.Com_Id = 11) OR
(a.id = 8 AND b.Com_Id = 12) OR
(a.id = 11 AND b.Com_Id = 13) OR
(a.id = 10 AND b.Com_Id = 14) OR
(a.id = 9 AND b.Com_Id = 15) OR
(a.id = 7 AND b.Com_Id = 16) OR
(a.id = 19 AND b.Com_Id = 17) OR
(a.id = 20 AND b.Com_Id = 19) OR
(a.id = 21 AND b.Com_Id = 20) OR
(a.id = 22 AND b.Com_Id = 21)
你就像同一个库中的2个表那样写语句就可以了,只不过要注意的地方就是表名前要增加库名来引用,如: "库名.dbo.表名"的形式:插入:
insert into text2.dbo.sp_qwe
select * from text1.dbo.sp_qwe where 查询条件
更新:
update t1
set t1.要更新的字段=t2.同名的字段
from text2.dbo.sp_qwe t1,text1.dbo.sp_qwe t2
where t1.关联字段=t2.关联字段
sql 两个数据库之间怎么更新数据--<a href="" target="_blank" class="baidu-highlight">触发器</a>可以,通过数据库2中的表B更新数据库1中的表A。
create trigger tgr_update
on 数据库2.dbo.B
for update
as
begin
update 数据库1.dbo.A set 数据库1.dbo.A.字段='值' from inserted where 数据库1.dbo.A.字段=inserted.字段
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)