title: Update multiple column from another table using sql server 2005
body: <p>I have one master table named <code>table1</code> where i store or update <code>mobileNo</code> data daily for a month. </p>
  
  <pre><code>;WITH table1 AS (SELECT * FROM (VALUES
  (9999999999, '01/10/2013', NULL, NULL, NULL, NULL),
  (9999999999, NULL, '02/10/2013', NULL, NULL, NULL),
  (9999999999, NULL, NULL, '03/10/2013', NULL, NULL),
  (9999999999, NULL, NULL, NULL, '04/10/2013', NULL),
  (9999999999, NULL, NULL, NULL, NULL, '30/10/2013'),
  (9999999999, NULL, NULL, NULL, NULL, NULL),
  (8888888888, '01/10/2013', NULL, NULL, NULL, NULL),
  (8888888888, NULL, '02/10/2013', NULL, NULL, NULL),
  (8888888888, NULL, NULL, '03/10/2013', NULL, NULL),
  (8888888888, NULL, NULL, NULL, '04/10/2013', NULL),
  (8888888888, NULL, NULL, NULL, NULL, '30/10/2013')) 
  as t(mobileno,date1,date2,date3,date4,date30))
  </code></pre>
  
  <p>And i have another table named <code>table2</code>  where i keep unique <code>mobileNo</code> against table1. Now i want to update <code>table2</code> against <code>table1</code> if any data exists in <code>table1</code>.</p>
  
  <pre><code>mobileno        date1      date2      date3      date4      date30
  --------------- ---------- ---------- ---------- ---------- ----------
  8888888888      01/10/2013 02/10/2013 03/10/2013 04/10/2013 30/10/2013
  9999999999      01/10/2013 02/10/2013 03/10/2013 04/10/2013 30/10/2013
  </code></pre>
  
  <p>However i tried the query like this</p>
  
  <pre><code>UPDATE table1
  set table1.date1 = 
  (SELECT date1 from table2 where table2.mobileno = table1.mobileno) 
  Where table2.mobileno = table1.mobileno
  </code></pre>
  
  <p>How do i update in a single query without repeating to update the 30 nos. of  date columns, please help me. Thanks in advance.</p>