码迷,mamicode.com
首页 > 数据库 > 详细

Sql server with as update用法

时间:2019-07-26 19:20:11      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:mes   用法   creat   create   ble   into   with as   update   sele   

create table t1
( id int,[names] varchar(100))

create table t2
( id int,[names] varchar(100))

insert into t1 values(1,‘t1‘);
insert into t1 values(2,‘t2‘);
insert into t1 values(3,‘t3‘);

 

insert into t2 values(1,‘ttt1‘);

with temp(id,names) as
(
select id,names from t1
)

Merge into temp as a
Using t2 as b on a.id=b.id
when MATCHED THEN
Update SET a.names = b.names;

 

Sql server with as update用法

标签:mes   用法   creat   create   ble   into   with as   update   sele   

原文地址:https://www.cnblogs.com/Impulse/p/11252088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!