SQL Table Variables

  • Thanks longobardia,

    I think he found it 2 posts back. I'm trying to get into the habit of helping people who are new to SQL with finding the problems/solutions themselves with a bit of guidance rather than just blindly giving the answer 🙂

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • longobardia (11/20/2008)


    Chris,

    I couldn't bare the pain any longer reading your suggestions.

    Let me give hime the answer:

    SELECT T1.ObjectID FROM....

    SELECT T2.ObjectID FROM ....

    see below:

    IF EXISTS(SELECT T1.ObjectID FROM @tmp_subjects t1

    INNER JOIN tkObjects o ON t1.ObjectID=o.ObjectID

    IF EXISTS(SELECT T2.ObjectID FROM @tmp_objects t2

    INNER JOIN tkObjects o ON t2.ObjectID=o.ObjectID

    Heh... and, yet, you're ok with all the RBAR calling a single row proc in the earlier post. 😉

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

  • I have to agree with Jeff. Keep the temporary tables and figure out how to get rid of the RBAR in your code. It's all the looping that is making your procedures slow, not the temporary tables. There may be a set-based solution to your problem, but nobody has tried to find it.

    We don't have enough information to work on it either. We would need the DDL for all the user defined tables in the procedure, sample data for the tables, the expected results from executing the procedure.

    Read the article in my signature block on asking for help for more information.

Viewing 3 posts - 16 through 17 (of 17 total)

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