• R.P.Rozema (1/16/2013)


    Excellent article indeed. However like in most articles on merge, you do not mention the fact that merge doesn't have a where clause. i.e. if you want to use only a part of a table as the merge target because your source data set only represents a subset of the data included in the entire table, without precautions the merge statement will delete all rows that are not in your subset.

    This is easily preventable by extending the "WHEN NOT MATCHED BY SOURCE" clause, ie:

    WHEN NOT MATCHED BY SOURCE AND T.TypeID = 1