title: SQL Server - How to Update Multiple Columns/Conditions and Ignore Certain Columns in WHERE statement
body: <p>I have two tables and would like to update table t in SQL Server 2008:</p>
  
  <p>table w:</p>
  
  <pre><code>+--------+----+------+------+------+
  | DataID | AFD|  PSD |  PFD | ASD  |    
  +--------+----+------+------+------+
  |      1 | B  | E    | A    |      |  
  |      2 | I  |      | B    |  W   |      
  |      3 |    |      | Y    |  D   |   
  |      4 |    | Q    |      |  T   |     
  |      5 | T  | E    | D    |  T   | 
  +--------+----+------+------+------+
  </code></pre>
  
  <p>table t:</p>
  
  <pre><code>+--------+----+------+------+------+
  | DataID | AFD|  PSD |  PFD | ASD  |    
  +--------+----+------+------+------+
  |      1 | A  | E    |      |  Z   |  
  |      2 | B  | F    | Y    |      |      
  |      3 | C  | G    | G    |  T   |   
  |      4 | B  | E    |      |      |     
  |      5 | T  | G    | Y    |  Z   | 
  +--------+----+------+------+------+
  </code></pre>
  
  <p>Question/Attempt: How to update table t checking for multiple conditions?</p>
  
  <p>Note: NULL is text not an empty column.</p>
  
  <pre><code>update t
  SET t.ACTFINISHDATE = GETDATE()
  ,t.PROJSTARTDATE = 
  (CASE 2
  WHEN t.PROJSTARTDATE = 'NULL' THEN t.PROJSTARTDATE = w.PROJSTARTDATE
  WHEN w.PROJSTARTDATE = 'NULL' THEN GETDATE()
  ELSE GETDATE()
  END)
  ,t.PROJFINISHDATE =
  (CASE 3
  WHEN t.PROJFINISHDATE = 'NULL' THEN t.PROJFINISHDATE = w.PROJFINISHDATE
  WHEN w.PROJFINISHDATE = 'NULL' THEN GETDATE()
  ELSE GETDATE()
  END)
  ,t.ACTSTARTDATE =
  (CASE 3
  WHEN t.ACTSTARTDATE = 'NULL' THEN t.ACTSTARTDATE = w.ACTSTARTDATE
  WHEN w.ACTSTARTDATE = 'NULL' THEN GETDATE()
  ELSE GETDATE()
  END)
  
  FROM w
    JOIN t ON w.DataID = t.DataID
  WHERE   ( ( cold IN ( 'A', 'B' ) 
         AND cols IN ( 'E', 'F' ) ) 
        OR ( cold = 'C' 
             AND cols = 'G' ) ) 
  </code></pre>
  
  <p>Question 2: How do I ignore update on C data in cold and F data in cols (so basically, ignore any data where Cold = C AND ColS = F)</p>
  
  <p>table t with additional columns:</p>
  
  <pre><code>+--------+-----+-------+
  | DataID | Cold|  ColS |    
  +--------+-----+-------+
  |      1 | A   | E     | 
  |      2 | B   | G     |      
  |      3 | A   | G     |  
  |      4 | B   | E     |   
  |      5 | C   | F     |
  |      6 | C   | F     |
  +--------+-----+-------+
  </code></pre>