Skip to content
Advertisement

ETL – Update Tables with potentially new records or updated records

I am trying to accomplish the following table update via an insert for an etl process:

  1. Add in a new records that did not exists
  2. Update any records that had updates
  3. Keep all the records in place that did not change

On the table I have a unique_id and an updated_date field when the record was updated ( or could serve as the date it was first created). Below is example code of two tables and a third I would want the output to be after an insert statement:

is there a better approach than the above ie an scd2 – if so why?

Advertisement

Answer

You can use the MERGE statement to accomplish this

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement