Merge from Production table to UAT table (which has keys).

  • This looks like the best approach to me.
    To avoid wasting time updating rows which have not changed, I'd suggest using

    ...WHEN MATCHED AND NOT EXISTS
           (
             SELECT
              s.ExchangeRate
             INTERSECT
             SELECT
              t.ExchangeRate
           ) THEN
      UPDATE SET ...

    I'd also suggest using
    MERGE fact.DailyExchangeRate WITH (HOLDLOCK) t
    to deal with some of the possible issues with MERGE.
    Finally, if your proc is in database DW, it is bad practice to use the DW prefix for referencing objects within that database, so I suggest that you use two-part object names only.


Viewing post 1 (of 2 total)

You must be logged in to reply to this topic. Login to reply