• I would have thought that a SQL CLR function would provide the ideal solution here?

    .NET is the right language to process complex types in a RBAR/loop manner; over TSQL's set based.

    It would also be faster I would suspect, though measurements aren't to hand.