sqlserver 实用的功能 upsert

merge into Target using Source

on (condition)

when matched then 

update set column1=value1

when not matched then

insert (column1,  column2) values (value1, value2);

解释:

Target : 目标表名

Source: 源表名

Condition 为匹配条件

matched时更新,not时则更新

猜你喜欢

转载自onlyor.iteye.com/blog/1477328