title: TSQL Maxrecursion on a cte
body: <p>I get this error:</p>
  
  <blockquote>
    <p>The maximum recursion 100 has been exhausted before statement
    completion</p>
  </blockquote>
  
  <p>when I run this function:</p>
  
  <pre><code>    WITH allDays AS (
  
          SELECT @DateEarly AS date
  
          UNION ALL
  
          SELECT DATEADD(dd, 1, date) as date
          FROM allDays s  
          WHERE DATEADD(dd, 1, date) &lt;= @DateLate
  
  
     )
      SELECT *
      from allDays 
      where dbo.isFestivo(date)&gt;0
  </code></pre>
  
  <p>I tried to append this option:</p>
  
  <pre><code>OPTION (MAXRECURSION 200);
  </code></pre>
  
  <p>but i get an error 156 before "option" word.
  Do you know why?</p>