• I'm not sure what you mean.

    "SELECT * FROM days" will fail because of recursion limit. But original idea was to get only the first Friday, the 13th. As there is always at least one such day in a year, there will be no more than 23 iterations.

    Is there something wrong with execution plan?

    Sorry for asking, but are you familiar with common table expressions (CTE)?