Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

MERGE Query

$
0
0

Hi,

Scenario is, our SSIS - SCD is taking a quiet bit of time to process.

We have source table + destination table + history table.

Data comes through source > gets compared against destination table.

Based on key columns....

If a record exists in source table but not in destination table (new records), we want to insert that into destination table.

If a record exists in source and destination table, and non-key columns are same, don't do anything.

If a record exists in source and destination table, and non-key columns are different (some or all), update those columns in destination table.

If a record does not exist in source but does exist in destination table, 

move those records from destination table to history table

delete those records from destination table.

I found information about how to insert/update...but not sure about the last part where we have to move them to history table and then delete.

Can you guys make some suggestion? (articles would be a plus).

T

H

X


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>