Database Reference
In-Depth Information
5. Log the upsert operation (optional).
A typical control flow design pattern is shown in
Figure 11-4
.
Figure 11-4
.
Using MERGE against a SCD table
Also note the large callout in
Figure 11-4
with the T-SQL code used for the
MERGE
statement. In the interest of maintaining focus, I won't try to provide comprehensive
coverage of the
MERGE
statement here, but I'll point out a couple of the high points:
• The
ON
clause (third line) indicates the field on which we join the
source data with the destination data. Note that we can use multiple
fields on which to align the two sets.
• The ten-line code block following
WHEN MATCHED AND NOT...
in-
dicates which of the fields will be checked to see if the data in the des-
Search WWH ::
Custom Search