I want to update a column in a specific table named Employeekopie1.
The column I'm trying to update is - FK_Profiel(values are type int)
The values I'm trying to put in a column FK_Profielare the values I get from the cursor. The cursor retrieves values from a column in another table, using joins to get the correct values.
The result of using the select query returns multiple rows with different values.
The first result of the select query is 114, which is correct. The problem is that this value is assigned to all fields of the column FK_Profiel, which is not my intention.
I want to assign all the values from a select query.
The code is as follows:
DECLARE @l_profiel int;
DECLARE c1 CURSOR
FOR select p.ProfielID
from DIM_Profiel p,DIM_EmployeeKopie1 e1,employee e
where e1.EmpidOrigineel = e.emplid and e.profile_code = p.Prof_Code
for update of e1.FK_Profiel;
open c1;
FETCH NEXT FROM c1 into @l_profiel
WHILE @@FETCH_STATUS = 0
BEGIN
SET NOCOUNT ON;
UPDATE DIM_EmployeeKopie1
set FK_Profiel = @l_profiel
where current of c1
end
close c1;
deallocate c1;
, , .