Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing the data in 2 tables on 2 servers

Status
Not open for further replies.

SuperComputing

IS-IT--Management
Oct 11, 2007
57
US
I apologize in advance, there's at least 3 forums this could fall into :)

My company has a psql based program that stores 'customers' in a local database. Our offsite website has a MySQL database that stores SOME of those customers as 'dealers'. There is a flag in the local table that specifies which 'customers' should be in the 'dealers' table. Both tables have a column called 'CustomerNumber' that identifies the customers/dealers. I have written a local asp page that will display all of the customers, and all of the dealers.

What I need to do is be able to display the differences between the 2 sets of CustomerNumbers. Mainly, which ones that are local that are not on the remote, and secondly, the ones that are remote that are not local. Can this be accomplished without a painstakingly slow loop? Is there a way that I can pull the data, then compare it?

Thanks in advance!

Code:
Set LocalConn = Server.CreateObject("ADODB.Connection")
LocalConn.Open = "DSN=CPDATA;"

Set RemoteConn = Server.CreateObject("ADODB.Connection")
RemoteConn.Open = "Driver={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Customers = "SELECT CustomerNumber FROM Customer WHERE Flag = 'Y' "
Dealers = "SELECT CustomerNumber FROM Dealers"

Set rsCustomers = LocalConn.Execute(Customers)
Set rsDealers = RemoteConn.Execute(Dealers)

     for each x in rsDealers.Fields	
        Response.Write(x.name)
     next
	do until rsDealers.EOF
	     for each x in rsDealers.Fields	
               Response.Write(x.value)
  etc... etc..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top