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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help creating a ms query!!! 2

Status
Not open for further replies.

domi1

IS-IT--Management
Aug 23, 2005
3
CA
I was wondering if anyone can help me create a sql query

I have 2 databases lets say A and B, and both contain a contacts table and ARE supposed to hold the same records but after running a query i found that Im missing about 400 records on database B

how can I find wich contacts are missing from database A

thanks!!
 
Does this work?

SELECT contactID,contact Name from
B.dbo.Contacts WHERE contactID NOT IN (
Select contactID from A.dbo.Contacts)

-DNG

 
Try this:
Code:
SELECT       a.contactID, b.contactID 
from         a.dbo.Contacts a
             left outer join b.dbo.Contacts b
             on (a.ContactID = b.ContactID)
where        b.contactID IS NULL

Regards,
AA
 
When I read your requirement again, I see that you have contradicting statements:

> i found that Im missing about 400 records on database B

which is what the code does.

But if next statement is true

> how can I find wich contacts are missing from database A

then you need left outer join on B instead.

 
thank you very much ! amrita418
that was exactly the query I was looking for I tested it and its working

the last request I have is is it possible to export the results of the query to dbf file or mdb file?

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top