• What if your UDF is a scalar detereministic UDF with a constant value passed in? How many times is this UDF executed:

    CREATE FUNCTION dbo.AbsoluteValue (@i INT)

    RETURNS INT

    WITH SCHEMABINDING

    AS

    BEGIN

    RETURN ABS(@i);

    END;

    GO

    SELECT dbo.AbsoluteValue(-10)

    FROM sys.columns;

    GO

    If SQL Server is executing a deterministic UDF with a constant parameter hundreds or thousands of times, it is seriously wasting resources.