SQL脚本-利用带关联子查询Update语句更新数据与连接远程服务器

  • A+
所属分类:网站建设
摘要

Update Table1 set c = (select c from Table2 where a = Table1.a) where c is null

--方法1:
Update Table1 set c = (select c from Table2 where a = Table1.a) where c is null 

--方法2:
update  A
set  newqiantity=B.qiantity
from  A,B
where  A.bnum=B.bnum 

--方法3:
update
    (select A.bnum ,A.newqiantity,B.qiantity from A left join B on A.bnum=B.bnum) AS C
set C.newqiantity = C.qiantity
where C.bnum =XX

连接远程服务器

--方法1:
select *  from openrowset('SQLOLEDB','server=192.168.0.67;uid=sa;pwd=password','SELECT * FROM BCM2.dbo.tbAppl')

--方法2:
select *  from openrowset('SQLOLEDB','192.168.0.67';'sa';'password','SELECT * FROM BCM2.dbo.tbAppl')

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: