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

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Compare 2 tables

Author  Topic 

Starting Member

8 Posts

Posted - 2004-11-10 : 06:17:54
Is there any way i can compare the records between 2 tables (table a and table b where order id is the same in both) and tell what the difference is between the 2 of them.


22859 Posts

Posted - 2004-11-10 : 07:04:50
use Google to search for a COMPARE script by Viktor Gorodnichenko (it may be on SQL Team too)

EDIT: It can be found here:

Go to Top of Page

Constraint Violating Yak Guru

278 Posts

Posted - 2004-11-10 : 08:03:17
[code]Select * from tblA where not exists
Select 1 from tblB
Where tblA.PK=tblB.Pk
)[/code]to find records in tblA that does not exists on tblB


A candle loses nothing by lighting another candle
Go to Top of Page

Dr. Cross Join

7423 Posts

Posted - 2004-11-10 : 09:30:15
also check out:

- Jeff
Go to Top of Page

SQL Natt Alfen

3279 Posts

Posted - 2004-11-10 : 19:07:49
binary_checksum can in some case give same checksum, see bol.

This will give records that are
1. different
2. in table a but not in table b, and vice versa

a.[order id],
a.col1, a.col2,,,,
b.[order id],
b.col1, b.col2,,,,
( select *, binary_checksum(*) as bchk from a ) as a
full join
( select *, binary_checksum(*) as bchk from b ) as b
on a.[order id] = b.[order id]
a.bchk <> b.bchk
or a.bchk + b.bchk is null

Go to Top of Page

Starting Member

2 Posts

Posted - 2006-03-17 : 13:26:04
Go to Top of Page

Dr. Cross Join

7423 Posts

Posted - 2006-03-17 : 13:40:57
golum1 -- I'm sure if you want to advertise at SQLTeam, Graz will be happy to quote you a fair price.
Go to Top of Page


3564 Posts

Posted - 2006-03-17 : 14:30:13
Dont think he's advertising, firefly is free, and it definately goes with the subject of this topic.

Keeping the web experience alive -- [url][/url]

RS Blog -- [url][/url]
Go to Top of Page

- Advertisement -