title: Script to migrate data between two SQL Server databases
body: <p>I have two SQL Server databases, and I need to write a script to migrate data from database A to database B. Both databases have the same schema.</p>
  
  <p>I must loop through the tables and for each table I must follow those rules:</p>
  
  <ol>
  <li>If the item I'm migrating does not exist in the target table (for example, the comparison is made on a column <code>Name</code>) then I insert it directly.</li>
  <li>If the item I'm migrating exists in the target table then I need to only update certain columns (for example, only update <code>Age</code> and <code>Address</code> but do not touch other columns)</li>
  </ol>
  
  <p>Can anyone help me with that script? Any example would suffice. Thanks a lot</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I just need an example for one table. No need to loop, I can handle each table separately (because each table has its own comparison column and update columns)</p>