• Jeff Moden (2/25/2013)


    Alan.B (2/25/2013)


    If i am understand right. Function can return only one value. am i right?

    Scalar functions return one value, table valued functions return a table variable.

    Inline Table Valued Functions (iTVF for short) return a result set even if that result set is a single element. Think of it as an Inline Scalar Function. The "inline" type of function is about 7 times faster than any scalar function and also works faster for MultiLine Table Valued Fuctions.

    I will confess, I have always used Scalar functions for returning a single value; I never thought to use an iTVF like that...

    Unless I am misreading your comment - you are saying that scalar functions are worthless? Are there any cases where you would Scalar function over an iTVF that returns a single element?

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001