The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
WHILE (Select Max (sa.SlotID) From SlotAvailability as sa join AvailabilityType as at on sa.availabilityid = at.availabilityID WHERE sa.MachineID = @MachineID and sa.availabilityid = 1) >= @counter Begin --checks to see if the counter matches a slotId that exists for the selected machine, or null in this case --else moves on to the next slotID before any processing gets done. If ( select slotid from slotavailability where exists (select slotID from slotavailability Where @Counter in (Select SlotID from slotavailability where machineID = @machineID and availabilityid = 1))) is null Begin SET @Counter = @Counter + 1 End Else Begin Set @SlotTimeCounter = (select slottime from slot where slotId = @Counter) Insert Into @DateResults Values (@Counter,@SlotTimeCounter, 'Available') SET @Counter = @Counter + 1 End END END