Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Want to compare records in 2 databases.

8 views
Skip to first unread message

Sammy Singh

unread,
May 22, 2013, 2:12:23 PM5/22/13
to
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

unread,
May 22, 2013, 4:18:12 PM5/22/13
to
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)
0 new messages