Wednesday, 3 February 2016

MSSQL - fix error - The statement terminated. The maximum recursion 100 has been exhausted before statement completion.

Watch this example on YouTube:

to fix the following error
The statement terminated. The maximum recursion 100 has been exhausted before statement completion.

replace
;with c as (
    select 1 as i
    union all
    select i + 1
    from c
    where i < 150
)
select * from c

with
;with c as (
    select 1 as i
    union all
    select i + 1
    from c
    where i < 150
)
select * from c
option (maxrecursion 0)

No comments:

Post a Comment