Scalar Functions x Table Functions

  • Hi everyone,

    In the following scenarios, does anybody know if there is a difference in performance?

    The first uses a SCALAR FUNCTION, while the second uses a TABLE FUNCTION.

    SELECTt1.Code,t1.Description, fn_ScalarFunction1(t1.Code) as xyz

    FROMTable1 t1

    WHERE….

    SELECTt1.Code, t1.Description, f1.xyz

    FROMTable1 t1

    OUTER APPLY fn_TableFunction1(t1.Code) as f1

    WHERE….

    I was wondering if we can say that one is always better than the other, or if it depends on something else.

    Thanks a lot,

    Luiz.

  • Check this good discussion here:

    http://www.sqlservercentral.com/Forums/Topic446308-360-1.aspx

  • It depends on what you are trying to do in the function.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi,

    Compare the execution plan.

    You will see the which provide the best performance for your case.

    Regards.

  • Thank you for your answers.

    As pointed, http://www.sqlservercentral.com/Forums/Topic446308-360-1.aspx covers this issue. I'll add my new questions to it.

    Luiz.

Viewing 5 posts - 1 through 4 (of 4 total)

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