title: import data from one table to another table
body: <p>I am using SQL Server 2008 Enterprise. I need to import all data from Server/Instance "Server Foo", Database "Foo" and table "Foo", into destination Server/Instance "Server Goo", Database "Goo" and table "Goo". Table Foo and Table Goo are of the same schema. If the same row exists for table Goo, I want to keep the origin data in Goo and ingore the import row in Foo (table Foo and table Goo both has a uniqueidentifier type column called CustomerID which acts as primary key and clustered index), just like ignore duplicate key does.</p>
  
  <p>I am looking for simple and reliable ways to write T-SQL to solve data export/import issue. Any reference samples?</p>
  
  <p>EDIT 1:</p>
  
  <p>I have tried the below solution using MERGE, but met with the following error from SQL Server Management Studio. Any ideas what is wrong?</p>
  
  <p>Some more information:</p>
  
  <p>LabTest1\SQLServer2008 => Server\Instance name;
  OrderDB => DB name;
  dbo => schema name;
  Orders => Table name.</p>
  
  <pre><code>merge into [dbo].[Orders] as Target
  using "LabTest1\SQLServer2008.OrderDB.dbo.Orders" as source
  on target.Hash = source.Hash
  when not matched then
  INSERT     ([Hash]
             ,[Order]
             ,[Name]
             ,[CreationTime]
             ,[Description])
       VALUES
       (
       source.[Hash], source.[Order], source.[Name], source.[CreationTime], source.[Description]
       )
  when MATCHED then
  ;
  </code></pre>
  
  <p>Error message:</p>
  
  <p>Msg 102, Level 15, State 1, Line 16
  Incorrect syntax near ';'.</p>
  
  <p>thanks in advance,
  George</p>