I need up update a schedule table. There is no join on these tables before the update. What I need to do is take the people in each group, for example the field techs, and loop through them and assign them each to a week. I have something that does update but it overwrites the last one inserted.
This is what I have so far:
DECLARE @id int DECLARE c1 CURSOR FOR select id from dbo.Employees where groupid = 5 and active = 1 OPEN c1 FETCH NEXT FROM c1 INTO @id WHILE @@FETCH_STATUS = 0 BEGIN UPDATE dbo.OnCallShifts_Test SET RTOCId = @id PRINT @id FETCH NEXT FROM c1 INTO @id END CLOSE c1 DEALLOCATE c1
Can anyone tell me what I need to do to make this work?