• No, it's actually much worse.

    I tested my function against 16540 row table.

    It returned result in 3..5 seconds (I'm not alone on that server )

    Than I started same query but using function [dbo].[CountDP].

    I's been 2 hours 50 minutes since then, it's still going.

    So, there is a reminder: avoid referencing tables inside UDF!

    Even if it's such "set based" table as Numbers.

    _____________
    Code for TallyGenerator