title: Copy Data and increment PK in destination table
body: <p>I have a temp table with data that needs to be split into 3 other tables. Each of those tables has a primary key that is not shared with each other or with the temp table. Here is a small sampling:</p>
  
  <p>Table 1</p>
  
  <pre><code>RSN     AGENT   STATUS  STATUS DECRIPTION
  0   280151  51  Terminated
  1   86  57  C/O Comp Agent Dele
  2   94  57  C/O Comp Agent Dele
  3   108 51  Terminated
  </code></pre>
  
  <p>Table 2</p>
  
  <pre><code>RSN     AGENT   CITY
  1   10  Englewood
  2   123 Jackson
  3   35  Eatontown
  4   86  Trenton
  </code></pre>
  
  <p>Table 3</p>
  
  <pre><code>RSN     AGT     SIGN    NO_EMP  START_DATE
  0   241008  Y   1   2002-10-31 00:00:00.000
  1   86  Y   0   2002-10-24 09:51:10.247
  2   94  Y   0   2002-10-24 09:51:10.247
  3   108 Y   0   2002-10-24 09:51:10.247
  </code></pre>
  
  <p>I need to check each table to see if the data in the temp table exists and if it does not I want to insert those rows with a RSN# starting with the max number in that table. So if I have 5000 records in the first table and I am adding 5000 new rows they will be numbered 5001 through 10000.</p>
  
  <p>I then need to check to see if any columns have changed for matching rows and update them.</p>
  
  <p>Thanks in advance for your assistance.</p>
  
  <p>Scott</p>