title: MS SQL Server - How to create a view from a CTE?
body: <pre><code>with cte as (
      select '2014-03-10 08:00:00' as Dates
      union all
      select '2014-05-11 14:00:00'
  )
  select * from cte 
  join someTable on 1=1 
  OPTION (MAXRECURSION 0)
  </code></pre>
  
  <p>The here above SQL is outputing like a charm  all hours between two dates and a field retrieved from a join with another table:</p>
  
  <pre><code>2014-03-10 02:00:00    A
  2014-03-10 02:00:00    B
  2014-03-10 03:00:00    A
  2014-03-10 03:00:00    B
  ...
  2014-05-11 13:00:00    A
  2014-05-11 13:00:00    B
  2014-05-11 14:00:00    A
  2014-05-11 14:00:00    B
  </code></pre>
  
  <p>I would like to create a view from that but I do not manage to do it. I tried several things but without success. The following is returning : <code>Incorrect syntax near the keyword 'OPTION'.</code></p>
  
  <pre><code>CREATE VIEW viewName as 
  with cte as (
      select '2014-03-10 08:00:00' as Dates
      union all
      select '2014-05-11 14:00:00'
  )
  select * from cte 
  join someTable on 1=1 
  OPTION (MAXRECURSION 0)
  </code></pre>