title: Update with a cursor in SQL Server 2008 R2
body: <p>I want to update a column in a specific table called <code>Employeekopie1</code>.</p>
  
  <p>The column I am trying to update is <code>FK_Profiel</code> (values are type <code>int</code>)</p>
  
  <p>The values I am trying to put in the column <code>FK_Profiel</code> are the values I am getting
  from a cursor. The cursor is getting values from a column in a different table, using joins to get the correct values.</p>
  
  <p>The result of the select query used returns multiple rows with different values.</p>
  
  <p>The first result of the select query is 114, which is correct. The problem is that this value is assigned to all the fields in the column <code>FK_Profiel</code>, which is not my intention.</p>
  
  <p>I want to assign all the values from the select query.</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>Please help, thx.</p>