//
you're reading...
SQL Server

The statement terminated. The maximum recursion 100 has been exhausted before statement completion

Forgetting to set the “maxrecursion” Option

Ever get this running a recursive CTE query? I have and every time I get this error  I kick myself, literally kick myself  for not including the “maxrecursion” option on my query. It’s quite an easy fix. Simply add the option (maxrecursion 0) at the end of your select from your CTE  and no more recursion issues. This option allows you to specify how often the CTE can recurse before generating an error. The Maxrecursion 0 allows infinite recursion.

Advertisements

About ldgaller

Accomplished Data Warehouse Architect, DBA and Software Architect with over 15 years of professional experience and demonstrated success designing and implementing solutions that improve business functionality and productivity. Highly diverse technical background with proven ability to design, develop and implement technology on an enterprise level. I approach all projects with passion, diligence, integrity, and exceptional aptitude.

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: