title: How to fetch a row from one table and insert it into another table and get new PK value
body: <p>I have two similar tables on different databases. </p>
  
  <pre><code>Database1/TableA
  
  Database2/TableA
  </code></pre>
  
  <p>I want to fetch a row from one table and insert it into other table on other server. Like:</p>
  
  <pre><code>Database1/TableA
  Id        State            Name
  500        OH              John  [Fetch this row]
  
  Database2/TableA
  Id        State            Name
  1          OH              John  [Insert and fetch PK '1']
  </code></pre>
  
  <p>I tried this using bulkcopy and it works fine. </p>
  
  <p>But problem is I need to get PK from the new insert as I need to populate another child table. </p>
  
  <p>Is there any better way to achieve this? Please on C# code, no database linking or SQL queries. Just C# solutions. Or if query can be used in C# code that is fine. Any working example code with Dataset or Datarow will be great help. </p>
  
  <p>Thanks!</p>