CTE loop in loop

oreb

New Member
situation: I got 2 tables. One where there are 2 fields StartDate & 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. I have next code and it insert perfect my line in the table Availability.\[code\]with View_Solidnet_Training as(select cast('2013-04-09' as datetime) DateValueunion allselect DateValue + 1from View_Solidnet_Trainingwhere DateValue + 1 <= cast('2013-04-11' as datetime))insert into OBJ_Availability select 34, DateValue, 'AM', 2, 'Test' from View_Solidnet_Training;\[/code\]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. So is there a possible solution, or should I make a new loop where I check if ID of the view is not zero?
 
Top