• I see what the error is, but I'm not sure what you want to do. Both functions seem unrelated, so having the same structure is illogical.
    Also, check the following article: How to Make Scalar UDFs Run Faster (SQL Spackle) - SQLServerCentral

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2