CTE looping query
问题 First I'll explain you the situation. I want to transfer data from one table(View_Solidnet_Training) to another(OBJ_Availability). There is one problem: In the view there is a Start- and EndDate! In OBJ_Availability every date has one record. So one line in the view has multi lines in the other table. I must work with CTE. So cursor is no option for me. The middle WITH runs perfect, but when I want to add an extra WITH to check if the ID isn't zero, it must change the variable @Start and @End