merge TableName as target using( values(‘FIELDVALUE1‘,‘FIELDVALUE2‘)) as source (FIELDNAME1,FIELDNAME2) on target.FIELDNAME1= source.FIELDNAME1 when matched then update set FIELDNAME2= source.FIELDNAME2 when not matched then insert (FIELDNAME1,FIELDNAME2) values (source.FIELDNAME1,source.FIELDNAME2);
这是用SqlServer 的MERGE来实现AddOrUpdate功能的
时间: 2024-11-03 03:27:23