• Actually, I am not too sure to understand what the table function is doing in all this...

    As for the speed, it's shockingly different!

    To retrieve about 1.5 million rows using a simple TSQL UDF took about 4 minutes.

    Replacing the TSQL UDF by a CLR function shrinks the 4 minutes to 18"

    Removing any function still gives me about the same (17").

    In other words, the CLR function is practically invisible in terms of performance! :w00t:

    In fact, I should have remembered because this is an experiment that Itzik Ben Gan had already demonstrated in his wonderful book "Inside SQL Server 2005 TSQL Querying"

    Silly me...