SQL脚本实用的

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

--方法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')
蓝色石头运营数据分析、网站建设、软件工具推荐编辑,欢迎投稿!
文章已创建 473

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部