skip the d*** loops. Use a numbers table to do this:
INSERT INTO @empShifts ([empID],[ShiftDate],[ShiftType],[StartDate] ,[EndDate])
select @input_empID ,
@current,
shift.patternShiftValue ,
@StartDate,
dateadd(day,-1*spt.number,@EndDate)
from @shifts_pattern as shift,
master..spt_values spt
where
PatternId=@last_shift_id+1
and spt.type='P'
and dateadd(day,-1*spt.number,@EndDate) between @current and @enddate
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?