title: Compare tables on different servers
body: <p>Using java and SQL Server 2008, I need to compare the content of two tables, the thing to bear in mind is that they are on different servers so I have a connection to the first server (lets call it conn1) and a connection to the second server (lets call it conn2). 
  I copy the tables into temp tables and then attempt to use the EXCEPT operator to compare the temp tables.</p>
  
  <p>A very basic example of trying to do this in java:</p>
  
  <pre><code>String s1 = "select * into #temp1 from FACTOR";
  String s2 = "select * into #temp2 from FACTOR'";
  String s3 = "SELECT * FROM #temp1 EXCEPT SELECT * FROM #temp2";
  
  Statement st = null;
  ResultSet rs = null;
  st = conn1.createStatement();
  st.execute(s1);
  
  Statement st1 = null;
  ResultSet rs1 = null;
  st1 = conn2.createStatement();
  st1.execute(s2);
  
  Statement st3 = null;
  ResultSet rs3 = null;
  st3 = conn2.createStatement();
  rs3 = st3.executeQuery(s3);
  </code></pre>
  
  <p>I'm getting the following error on the last line in the above code snippet:</p>
  
  <pre><code>Stack trace:java.sql.SQLException: Invalid object name '#temp1'.
  </code></pre>
  
  <p>Is it because I'm using the two connections to the different servers, conn2 can't see #temp1?</p>
  
  <p>Any ideas how I could acheive what I'm trying to do?</p>
  
  <p>Thanks.</p>