Discussion:
Want to compare records in 2 databases.
(too old to reply)
Sammy Singh
2013-05-22 18:12:23 UTC
Permalink
I have two databases Database1 and Database2
Both databases have a table called acctsub
The values in the table are
CPNYID ACCT SUB USER1 USER2


I want to compare the two databases and see which distinct(CPNYID,ACCT,SUB) values are in Database1 but not in Database2.
I am looking the UNIQUE (CPNYID,ACCT,SUB) Combos that are in one database but not in the other database.

Any help would be highly appreciated.
Thanks
rpresser
2013-05-22 20:18:12 UTC
Permalink
Post by Sammy Singh
I have two databases Database1 and Database2
Both databases have a table called acctsub
The values in the table are
CPNYID ACCT SUB USER1 USER2
I want to compare the two databases and see which
distinct(CPNYID,ACCT,SUB) values are in Database1 but not in
Database2.
I am looking the UNIQUE (CPNYID,ACCT,SUB) Combos that are in one
database but not in the other database.
Any help would be highly appreciated.
Thanks
SELECT CPNYID, ACCT, SUB from Database1.dbo.acctsub AS DB1
WHERE NOT EXISTS (
SELECT * FROM Database2.dbo.acctsub AS DB2
WHERE DB1.CPNYID=DB2.CPNYID AND DB1.ACCT=DB2.ACCT AND DB1.SUB=DB2.SUB)
Continue reading on narkive:
Loading...