title: SQL Server: Alternative of long CASE statement
body: <p>I have a very long <code>CASE</code> statement and it makes the query very long. Is there an alternative way? Does the long <code>CASE</code> statement impact the performance? I see people are recommending <code>COALESCE</code> but I'm not sure if this is a good alternative in my query.  </p>
  
  <p>The example below, a, b, c, d, e, f are columns from a table but I'm just using the letter here to make an example. </p>
  
  <pre><code>UPDATE table
  SET totalAmt = CASE   
                   WHEN product_id = 1  THEN a*b*c*d
                   WHEN product_id = 2  THEN c*d*e + 1
                   WHEN product_id = 3  
                     THEN 
                       CASE WHEN term = 12 THEN b*c*d*e ELSE a*b*e*f END
                   WHEN product_id = 4   THEN a+b+c+d
                   etc.....
                 END
  FROM table
  </code></pre>