Re: Comparing Data between Tables
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Nov 2005 23:40:33 +0100
On Wed, 16 Nov 2005 11:53:09 -0800, Randaddyz wrote:
>I messed up and now we have two tables that have slightly different
>information. What is a query that would allow me to look at the data
>differences between the two tables?
Hi Randaddyz,
You could use something like below to check for differences:
SELECT a.Column1, a.Column2, a.Column3, ..., a.ColumnN,
b.Column1, b.Column2, b.Column3, ..., b.ColumnN
FROM TableA AS a
FULL OUTER JOIN TableB AS b
ON a.Column1 = b.Column1
AND a.Column2 = b.Column2
AND a.Column3 = b.Column3
.......
AND a.ColumnN = b.ColumnN
WHERE a.ColumnX IS NULL
OR b.ColumnX IS NULL
Make sure to include ALL the tables columns in the ON clause.
Make sure that the column chossen for ColumnX does NOT allow NULLs.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
.
- Prev by Date: Re: Conditional Join
- Next by Date: Re: Grouping by Distinct
- Previous by thread: Re: Conditional Join
- Next by thread: Re: Grouping by Distinct
- Index(es):
Relevant Pages
|
|