title: how to update table1 with records from table2 using t-sql
body: <p>I have two tables:</p>
  
  <p><code>Table1</code>:</p>
  
  <pre><code>RulesVectorID(nullable, primary),Weight,IsDeleted
  </code></pre>
  
  <p><code>Table2</code>:</p>
  
  <pre><code>RulesVectorID(forigen) , Weight,IsDeleted, NumberOfOffers, other fields...
  </code></pre>
  
  <p>I want to do tow things:</p>
  
  <ol>
  <li><p>assign <code>Id</code> to all rows in table1 <code>where RulesVectorID ==null</code></p>
  
  <p>I tried this:</p>
  
  <pre><code>UPDATE myTable1
  SET RulesVectorID = SELECT MAX(RulesVectorID) + 1 FROM myTable1,
  WHERE RulesVectorID IS NULL
  </code></pre></li>
  <li><p>To rows added in step (1) I want to copy their <code>Weight, IsDeleted</code> columns and add 1 to their <code>NumberOfOffers</code></p>
  
  <p>I tried this:</p>
  
  <pre><code>INSERT INTO myTable2 (Weight, IsDeleted, NumberOfOffers, RulesVectorID) 
  VALUES (
    SELECT Weight, IsDeleted, 1, RulesVectorID 
    FROM myTable1 
    WHERE myTable1.RulesVectorID NOT IN (SELECT RulesVectorID FROM myTable2))
  </code></pre></li>
  </ol>
  
  <p>Is there any cleaner way to do it?</p>