title: UPDATE Multiple columns Using CASE in SQL Server 2008
body: <p>I have the following SQL statement:</p>
  
  <pre><code> update data 
    set [sub_st_pc]= 
      case 
            when [R 6] is not null  then [R 6] 
        when [R 5] is not null  then [R 5]
        when [R 4] is not null  then [R 4]
        when [R 3] is not null  then [R 3]
        when [R 2] is not null  then [R 2]
        else sub_st_pc
      end
  </code></pre>
  
  <p>but I need to update another column according to each when, something like this:</p>
  
  <pre><code> when [R 6] is not null  then [R 6], [temp] = 6
   when [R 5] is not null  then [R 5], [temp] = 5
  </code></pre>
  
  <p>which I know it's wrong. </p>
  
  <p>Any ideas?</p>