• I don't have (unpaid 😎 ) time to give it a go, but I would look to unwind that logic into the SELECT statement if possible.

    Also, to validate that the UDF is the cause of your perf issues, run the query with some action on that column. Check for blocking/locking, query plan, stats IO, etc. All the usual suspects...

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service