This is real brief:
Looked at query plans, and put indexes on as suggested, but the index update was too expensive (running time ~ 1 minute). so faster without indexes
Set-Based is the clear winner. CLR is interesting, as this was the optimised algorithm, and it didn’t come close to the un-optimised UDF.
Conclusion: it is faster to keep it in SQL