Two Temp Tables within a Proc

  • So did that work and produce the same results as your original?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • I'm working on refactoring and implementing as such. I will let you guys know of my results when doing so. Sorry for the delayed responses, but have some other things that are currently taking precedence.

  • That worked! I got the same results that I initially had from using the while the loop and iterating over the temp tables.

  • Very cool. Thanks for the feedback, Dan.

    --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)

  • No thank you and everyone else for the insight. There's always more than one way to do something, but at the end of the day make sure that it's done in the best possible way. Once again thanks.

  • John Rowan (6/4/2010)


    In fact, since your Table A will only ever hold one value (since you are not getting this from a table in the DB, but from the @ID parameter), you don't even need that table. You can run a simple SELECT against your tblSomeType to get your results. This will make your solution SET based (no cursors) and remove the overhead of the temp tables.

    John, I assumed that TableA was being inserted into from another table, and could have multiple rows. I figured he just threw that simple insert in to give some test data.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

Viewing 6 posts - 16 through 20 (of 20 total)

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