How to use temporary table in function

  • RichB (7/22/2011)


    I am torn between considering this genius or madness...:pinch:

    Heh... I've found there's not much difference. 😀 The quality of the outcome is normally the determining factor.

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

  • In a personal database project I've been using a temp tables in all my udf's cause I need results that I can't generate with my current tables.

  • Very sneaky! Thank you for sharing 🙂

  • your solution woul be helpful in achieveing better performance using a temp table rather than a table variable insofar as statistics updates are concerned, which do no take palce against table variables but do on temp tables

  • Should be filed under the "SQL Hacks" category 😀

    --
    :hehe:

  • A table variable seems like a better solution to me

  • We've already discussed that a bit Please read the full thread.

    Jakub

    __________________________________________________________________________________________SQLTreeo.com - My Blog and Free SSMS Productivity Add-In

  • Jim Wolgamot (7/27/2011)


    A table variable seems like a better solution to me

    In most cases, I'd agree. It's nice to have this wonderful trick available, though.

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

  • Certainly makes for a lively discussion.:cool:

Viewing 9 posts - 31 through 38 (of 38 total)

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