Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Table matching

Author  Topic 

Knarf180
Starting Member

42 Posts

Posted - 2004-10-01 : 09:16:16
I have 2 tables, Table1 and Table2. Both tables have 2 matching fields which contain the same data "linking" them together.

Ex. Table1.Field1 = Table2.Field1
Table1.Field2 = Table2.Field2

My problem is that it seems that Table2 has a few records which do not have partners in Table1. These need to be documented and then removed. I know the JOIN command can find matches between tables, but how would one go about finding everything that does not correspond?

Thanks a ton,
- Frank

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-10-01 : 09:27:58
read up on LEFT OUTER JOIN in books on-line.

- Jeff
Go to Top of Page

Knarf180
Starting Member

42 Posts

Posted - 2004-10-01 : 09:42:20
Select * from Table1 where not exists (
Select * from table2 where
Table2.Field1 = Table1.Field1
AND
Table2.Field2 = Table2.Field2
)

Google is being good to me today. Thanks much for the reply jsmith.
Go to Top of Page
   

- Advertisement -