title: How to update particular column fields with while loop
body: <p><strong>SQL Server 2008</strong></p>
  
  <p>My SQL table is Like below</p>
  
  <pre><code>----------------------------------------
  **name  department  fee_paid    id**
  ----------------------------------------
  Farooq  ECE          10000     NULL
  Khan    EEE          20000     NULL
  Syed    Chemistry    4000      NULL
  Syed    Chemistry    14000     NULL
  Yousuf  Physics      2000      NULL
  Yousuf  Physics      18000     NULL
  Zubair  EEE          4000      NULL
  ----------------------------------------
  </code></pre>
  
  <p>now i wish to fill data in id fields like below</p>
  
  <pre><code>----------------------------------------
  **name  department  fee_paid    id**
  ----------------------------------------
  Farooq  ECE          10000     1000
  Khan    EEE          20000     1001
  Syed    Chemistry    4000      1002
  Syed    Chemistry    14000     1003
  Yousuf  Physics      2000      1004
  Yousuf  Physics      18000     1005
  Zubair  EEE          4000      1006
  ----------------------------------------
  </code></pre>
  
  <p>i tried like below but it stores same value in all id fields..I know as i miss my where condition in update query below.But how i use where condition with above table criteria because it has duplicates ?</p>
  
  <pre><code>declare @i as int =1000
  while @i&lt;=1006
  begin
      update flatfile set id=@i
      set @i+=1
  end
  </code></pre>