• Could you please post the definition of the function? This can help us to focus to problems in your UDF instead of discussing potential problems with any UDF.

    Generally, the parameter sniffing behaviour is possible with Transact SQL functions too (in addition to SPs), but let's see first which type of UDF you are using and the function definition.

    ___________________________
    Do Not Optimize for Exceptions!