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.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Compare 2 tables
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

8 Posts

Posted - 11/10/2004 :  06:17:54  Show Profile
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.


United Kingdom
22859 Posts

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

EDIT: It can be found here:


Edited by - Kristen on 10/31/2005 13:46:45
Go to Top of Page

Constraint Violating Yak Guru

278 Posts

Posted - 11/10/2004 :  08:03:17  Show Profile
Select * from tblA where not exists
    Select 1 from tblB
    Where tblA.PK=tblB.Pk
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 - 11/10/2004 :  09:30:15  Show Profile  Visit jsmith8858's Homepage
also check out:

- Jeff
Go to Top of Page

SQL Natt Alfen

3279 Posts

Posted - 11/10/2004 :  19:07:49  Show Profile
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 - 03/17/2006 :  13:26:04  Show Profile
Go to Top of Page

Dr. Cross Join

7423 Posts

Posted - 03/17/2006 :  13:40:57  Show Profile  Visit jsmith8858's Homepage
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

Flowing Fount of Yak Knowledge

3564 Posts

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

Keeping the web experience alive --

RS Blog --
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000