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 2005 Forums
 Transact-SQL (2005)
 Compare data in two tables (filter unmatched data)

Author  Topic 

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2008-08-25 : 12:06:32
There are two tables that should contain the same data values (though there are nulls) with column names slightly different.

My question is, how to compare the data from the two tables and select only those rows where the data in any given column does not match and adding a count to count the no. of unmatched?

Example how one database is (suppose to have at least 50 columns and many data values). There is another database that contains similar data but slightly diff column names.

id name food
1 susan maggi mee
1 susan mee
2 mike laksa
2 mike curry
2 mike chicken
3 billy laksa
3 billy chicken
4 ben null
5 sandy mee


Do i need to use Join method? How do i do this?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-08-25 : 13:11:10
Do a Search for "Compare Two Tables" and you will get several ways to compare tables. Here a couple of those links which might help:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=108339
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=106801
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=96546
Go to Top of Page
   

- Advertisement -