When data is imported, there are updates. If no data is inserted, there is no CREATE? Trigger? Tr_bank3? ON? Bank3AFTER? INSERTAS ?????? Update? Bank1? Set? Bank1.fmoneybank1. fmoney + c. ??????? From ????????? (Select? Fid, sum (case? When? TYPE0? Then? Fmoney? When? Type1? Then? -Fmoney? End )? As? A? Fr
When data is imported, there are updates. If no data is inserted, there is no CREATE? Trigger? Tr_bank3? ON? Bank3AFTER? INSERTAS ?????? Update? Bank1? Set? Bank1.fmoney = bank1.fmoney + c. ??????? From ????????? (Select? Fid, sum (case? When? TYPE = 0? Then? Fmoney? When? Type = 1? Then? -Fmoney? End )? As? A? Fr
An update exists during data import, and an insertion does not exist. <无>
CREATE?trigger?tr_bank3?ON?bank3AFTER?INSERTAS??????Update?bank1?set?bank1.fmoney=bank1.fmoney+c.a???????From?????????(select?fid,sum(case?when?TYPE=0?then?fmoney?when?type=1?then?-fmoney?end)?as?a?From?bank3?group?by?Fid)?C?????where?????????C.FID=bank1.FID?????????AND?EXISTS(SELECT?1?FROM?INSERTED?WHERE?Fid=bank3.Fid))?????insert?into?bank1?????select?????????fid,????????sum(case?when?TYPE=0?then?fmoney???when?type=1?then?-fmoney?end)?as?a?????from?????????bank3?AS?a????WHERE?????????EXISTS(SELECT?1?FROM?INSERTED?WHERE?Fid=a.Fid)????AND?????????NOT?EXISTS(SELECT?1?FROM?bank1?WHERE?Fid=a.Fid)????group?by?Fid
MERGE [target] tusing [source] s on t.id = s.idwhen matched then update t.name = s.name, t.age = s.age -- use "rowset1"when not matched then insert values(id,name,age) -- use "rowset2"when source not matched then delete; -- use "rowset3"