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
 General SQL Server Forums
 New to SQL Server Programming
 Check whether 2 tables are differenet

Author  Topic 

mavershang
Posting Yak Master

111 Posts

Posted - 2008-12-02 : 17:02:24
Hi guys,
Here is my question.

I have 2 tables (maybe just temporary tables). I want to check whether they are different and return the number of the different columns.

Is there any way to do this?

Thanks.

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-12-02 : 17:19:24
please illustrate it...
Go to Top of Page

mavershang
Posting Yak Master

111 Posts

Posted - 2008-12-02 : 17:27:22
The 2 tables contain the same columns. I just want to see whether the 2 tables are different. and if there is any difference, return the number of the different rows.

for example:

table A:
col1 col2 col3
1 1 1
2 2 2
....

table B:
col1 col2 col3
1 1 1
3 3 3
......



quote:
Originally posted by hanbingl

please illustrate it...

Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-12-02 : 17:35:24
[code]select count(*) from
(
select * from A
EXCEPT
select * from B
)t[/code]
Go to Top of Page

mavershang
Posting Yak Master

111 Posts

Posted - 2008-12-02 : 17:47:25
Thanks a lot. it is very helpful

quote:
Originally posted by hanbingl

select count(*) from 
(
select * from A
EXCEPT
select * from B
)t


Go to Top of Page
   

- Advertisement -