• realvilla (6/17/2013)


    Sorry, I totally missed the best practices the first time around. I will work on that this afternoon. It's exciting to think of accomplishing my goal without loops. That should be MUCH faster. I take it that "merge" is not the best way to go. I'll test my table creations and inserts before posting. Thanks.

    No problem. It is hard to know what to post and how to make it easy until you have done it a couple times. 😀

    I don't think MERGE is what you want here. From BOL:

    MERGE - Performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found in the other table.

    You are always doing an update and are not concerned about the results of a join to make a decision.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/