title: Fill multiple empty rows
body: <p>I'm tryting to fill empty rows from my table . Here is the example from my table.</p>
  
  <pre><code>ID | Code      | 
  1    NULL
  2    NULL
  3    NULL
  </code></pre>
  
  <p>what i want is </p>
  
  <pre><code>  ID |     Code      | 
      1    KL0000001
      2    KL0000002
      3    KL0000003
  </code></pre>
  
  <p>I'm using sql server 2008 and here is my script so far :</p>
  
  <pre><code>declare @jml as int;
  declare @no as int = 1; 
  declare @kode as varchar(50);   
      set @jml = (SELECT COUNT(IdArealeader) FROM arealeader);
      set @kode = (select case 
                   when right(max(KodeareaLeader),7) is null then 'KL0000001' 
                   else ('KL' + RIGHT('0000000' + cast(right(max(KodeareaLeader),7) + 1 as nvarchar),7)) 
                   end KodeareaLeader from arealeader)
  while @no &lt; @jml begin  
      update arealeader set KodeareaLeader = @kode;
  END
  </code></pre>