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)
 Compare 2 tables

Author  Topic 

Babli
Yak Posting Veteran

53 Posts

Posted - 2007-02-16 : 00:44:35
Hi,

I have two tables with the same set of columns
I need to compare the rows among the 2 tables.

How do i do that.

Thanks,
Babli

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-16 : 00:57:53
something like this

select *
from table1 t1 inner join table2 t2
on t1.pkcol = t2.pkcol
where t1.col1 <> t2.col1
or t2.col2 <> t2.col2
. . .



KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-16 : 00:58:40
or use LEFT / RIGHT / FULL OUTER JOIN if you have mismatched rows in the tables


KH

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-16 : 01:14:21
[url]http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -