title: CTE loop in loop
body: <p>situation: I got 2 tables. One where there are 2 fields StartDate &amp; EndDate. And one table where there is only one field date. So when you got 3 days between Start- and Enddate. He must insert 3 rows in the new table. </p>
  
  <p>I have next code and it insert perfect my line in the table Availability.</p>
  
  <pre><code>with View_Solidnet_Training as
  (
  select  cast('2013-04-09' as datetime) DateValue
  union all
  select DateValue + 1
  from View_Solidnet_Training
  where DateValue + 1 &lt;= cast('2013-04-11' as datetime)
  )
  insert into OBJ_Availability  
  select 34, DateValue, 'AM', 2, 'Test' from View_Solidnet_Training;
  </code></pre>
  
  <p>But now, after he inserts the lines in the new table, he stops. But after the loop, he must change the the Start and EndDate again in the new values of the next row in the view: View_Solidnet_Training. </p>
  
  <p>So is there a possible solution, or should I make a new loop where I check if ID of the view is not zero?</p>