0
votes

I am trying to write a query logic to capture all changes from the source.

Merge should compare the keys in source and target and process the data accordingly. Below is an example, how can we achieve this in SQL server.

MERGE <target_table> [AS TARGET]
USING <table_source> [AS SOURCE]
ON <search_condition>
[WHEN MATCHED 
   THEN <merge_matched> ]
[WHEN NOT MATCHED [BY TARGET]
   THEN <merge_not_matched> ]
[WHEN NOT MATCHED BY SOURCE
   THEN <merge_matched> ];

In snowflake, I get below error while trying something similar, Error SQL compilation error: syntax error line 7 at position 17 unexpected 'by'. syntax error line 8 at position 17 unexpected 'by'.

Is there a way in snowflake to handle 'when not matched by target' and 'when not matched by source' logic?

Thank you.