• The Dixie Flatline (9/23/2016)


    If you haven't read up on the MERGE operation in TSQL, be sure to do so. It allows you to insert and update (and d elete if need be) in a single query. Look at the sample queries HERE and try to adapt them to your issue.

    Hint: Example A is just what you're trying to do: Update where a row exists, and insert where a row doesn't exist.

    If you have any questions, post your code up here and we'll have a look at it.

    I prefer the individual commands rather than Merge. There have been too many problems with it for me to trust it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)