SqlServer Merge AddOrUpdate data
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功能的