Home Forums SQL Server 2008 T-SQL (SS2K8) How to use values keyword as parameter of a function RE: How to use values keyword as parameter of a function

  • ScottPletcher (11/30/2012)


    Jeff Moden (11/29/2012)


    capnhector (11/29/2012)


    EDIT: This is also for me to play with a couple of things and get more experience with them. so it may not be fast or work in your situation but does use some things i have been studying.

    No.... you're absolutely on the correct path. The MIN=MAX method the others used is twice as slow as the original function. You can make it a bit faster still by turning it into an iTVF instead of a scalar function. And lose the join. If you rework the GenericTable TYPE just a bit, you won't need it. Give it a shot. You've got this, Cap'n!

    Really??

    Doesn't the DISTINCT require an (expensive) sort but min/max don't?

    Correct but the min/max still turns out slower. I'll try to remember to post my test code when I get home from work.

    I also have an idea for solving the "base" problem here that might make both solutions seem slow.

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