Ищем журнал запросов c в операторе MERGE
MERGE <statement>
WHEN MATCHED
UPDATE active=1, value='testnew' where field='1200' and id=4
UPDATE active=0 where field='1200' and id <> 4 --This update is based on first update
WHEN UNMATCHED <statement>
До MERGE
;
id field value active
--------------------------
1 1200 hai 1
2 1200 hello 1
3 1200 hi 1
4 1200 test 1
После MERGE
:
id field value active
----------------------------
1 1200 hai 0 --Update active=0 for all other records with same field =1200
2 1200 hello 0 --Update active=0 for all other records with same field =1200
3 1200 hi 0 --Update active=0 for all other records with same field =1200
4 1200 testnew 1 --MATCHED CASE id=4, UPDATE value