• Jeff Moden (2/27/2013)


    TheSQLGuru (2/27/2013)


    You may THINK you want to do a Scalar UDF, but you probably don't. I wrote a chapter for the SQL Server MVP Deep Dives 2 book entitled "Death by UDF". It is a very aptly named missive. Please do everything in your power to avoid the UDF and inline the code where you need it.

    Oh, I haven't tested it, but I wonder if UDFs can call UDFs ...

    Yes they can. if they're not iTVFs, it about as joyous as an aggregated view calling an aggregated view.

    Which could get very aggregating.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden