title: UPDATE, with CASE statement, ignoring NULL values
body: <p>My code below isn't performing well on my attempt to update a table with a little more than 100,000 rows.</p>
  <p>I have about 2500 values in which the first value in a sequence is NULL, as a result that row and the following sequences are not getting updated.</p>
  <p>Additionally, about 5000 rows are also not updating because they do not exist in the second of the two tables (table 1 = dbo.abc / table 2 = dbo.abc_d)</p>
  <p>Regarding the second issue, I can write a second query just for that table, but I am stuck on the first issue. If you have any advice on improving this query for either issue it would be appreciated.</p>
  <pre><code>UPDATE dbo.abc abc
  SET    vcn1 = ( CASE
                    WHEN abc.chan_id1 IS NOT NULL THEN abc.chan_id1
                    WHEN abc.chan_id2 IS NOT NULL THEN abc.chan_id2
                    WHEN abc.chan_id3 IS NOT NULL THEN abc.chan_id3
                    --omitting this chuck for readability
                    WHEN abc_d.chan_id34 IS NOT NULL THEN abc_d.chan_id34
                    WHEN abc_d.chan_id35 IS NOT NULL THEN abc_d.chan_id35
                    WHEN abc_d.chan_id36 IS NOT NULL THEN abc_d.chan_id36
                  END ),
         vcn2 = ( CASE
                    WHEN abc.chan_id1 IS NOT NULL AND abc.chan_id1 != abc.vcn1 THEN abc.chan_id1
                    WHEN abc.chan_id2 IS NOT NULL AND abc.chan_id2 != abc.vcn1 THEN abc.chan_id2
                    WHEN abc.chan_id3 IS NOT NULL AND abc.chan_id3 != abc.vcn1 THEN abc.chan_id3
                    --omitting this chuck for readability
                    WHEN abc_d.chan_id34 IS NOT NULL AND abc_d.chan_id34 != abc.vcn1 THEN abc_d.chan_id34
                    WHEN abc_d.chan_id35 IS NOT NULL AND abc_d.chan_id35 != abc.vcn1 THEN abc_d.chan_id35
                    WHEN abc_d.chan_id36 IS NOT NULL AND abc_d.chan_id36 != abc.vcn1 THEN abc_d.chan_id36
                  END )
  FROM   dbo.abc_d abc_d
  WHERE  abc.abc_id = abc_d.abc_id; 
  </code></pre>