Hello Sergey
Have to reactivate this thread...
Trying to use Merge but it does not work as I am expecting.
The sample from Wiki does not work – using dot-notation for fields is throwing errors!?
Found a sample from Ruslan that works but it is too simple.
this works without throwing an error:
MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer)
WHEN MATCHED THEN
UPDATE SET name = isource.name
this is throwing an error:
MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode = mtarget.barcode)
WHEN MATCHED THEN
UPDATE SET name = isource.name
this works without throwing an error:
MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode <> mtarget.barcode)
WHEN MATCHED THEN
UPDATE SET name = isource.name
**********************************************************
I want to do anything like this:
MERGE main as mtarget
USING imp as isource ON (isource.artikelnummer = mtarget.artikelnummer AND isource.barcode = mtarget.barcode)
WHEN NOT MATCHED BY TARGET THEN
INSERT(artikelnummer, barcode, name) VALUES(isource.artikelnummer, isource.barcode, isource.name)
WHEN MATCHED THEN
UPDATE SET mtarget.name = isource.name
and a second one to delete:
MERGE main as mtarget
USING imp as isource
ON (isource.artikelnummer = mtarget.artikelnummer and isource.barcode = mtarget.barcode AND remove = 1)
WHEN MATCHED THEN
DELETE
What did I misunderstand?
How to make it work?
Best regards.
Chris