• As always, Great Article Jeff! :-D:-D:-D

    You know, I think that I noted this basic problem with SET STATISTICS (that it adds a per-statement overhead) way back in my "15 Ways To Lose Your Cursors Article, Part 2"[/url], making it inappropriate for measuring Cursor performance, but it never occurred to me that the same problem would apply to measuring UDF's. Duh!!! :w00t:

    Anyway, great catch on that Jeff.

    However, there is a mysterious coda to your background on scalar UDF's. It turns out that there really is an Inline Scalar UDF object type in SQL Server, as described here in the 2005 documentation. It says:

    User-defined scalar functions return a single data value of the type defined in the RETURNS clause. For an inline scalar function, there is no function body; the scalar value is the result of a single statement.

    (emphasis mine)

    You can confirm this with the following query:

    SELECT name

    FROM master..spt_values

    WHERE type = 'O9T'

    AND name LIKE '%function%'

    So as far back as SQL 2005, they actually had the object-type for it, however, AFAIK, none exist (not even in the hidden [mssqlsystemresource] database) and there's no syntax to create one. So it appears that this is something that Microsoft must have anticipated in the run-up to SQL Server 2005 by adding a type for it (and doc!), but never actually implemented for some reason. Even odder, they never took it out of the doc, it's still there in the 2012 version.(!)

    Though it is one of the single most requested features for all of Ms Sql Server. Primarily because the default UDF's are still slower (even with Jeff's measurement corrections) and we end up having to back-end ITVF's to get the same effect. (clumsy, but it works).

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]