Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many maximum recursion possible for CTE in SQL server?

How many maximum recursion level possible for CTE in SQL server? If maximum recursion level is reached then what are the alternative way?

like image 581
Paresh Avatar asked Apr 18 '26 10:04

Paresh


1 Answers

By default, it's 100.

You can change it on per-query basis by appending a hint:

OPTION (MAXRECURSION N)

to the end of the query.

OPTION (MAXRECURSION 0)

means no explicit limit.

When the recursion limit is reached, an error is raised and the query breaks.

like image 129
Quassnoi Avatar answered Apr 21 '26 01:04

Quassnoi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!