Hello Friends,

Just before one day i got one request from my client he wants to compare two database tables which located on the two different servers.

i thought how can i do this with sql server and i found one terrific solution to achieve same task. so all the sql server programmers and .net programmers who stuck on same issue here is the solution for you guys.

i take one example to describe you how can you do with a simple query or store procedure,

i have two servers first server name is A2 and second server name is A4 in both the server there are two different database A2 has the database name UserCatalog and second server A4 has the database name CatalogRequests.

Now both the database has different tables name. first UserCatalog has the table name is tb_user and second database CatalogRequests has the table name is tb_catalog.

now both the table have the conman field which is rowid.

the requirement is compare both the tables and get the values from tb_catalog and not in the tb_user table.

here is the query to achieve same task which describes you above.

select * from A4.CatalogRequests..tb_catalog where rowid Not In (Select rowid from A2.UserCatalog ..tb_User) order by rowid desc;

so here is the description what above stuff mean.

to access different server with different database servername.databasename..tablename
make sure after database name when you write the table name in between use “..”

please reply me if you have any kind of suggestion or if you have any kind of problem.

Thanks in Advance.

Tags:

This entry was posted on Monday, August 3rd, 2009 at 1:07 am and is filed under Sql Server. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment