Compare two columns in different tables and extract difference between them

I am using MS-SQL Query Analyser.

I have two tables ("A" & "B") that both have a column named "X".  Both columns contain the same type of information.  There are some differences betwen the contents of the 2 columns.

In particular, Table A col X contains a list of approx 100000 distinct numbers.  Table B col X contains approx 1 million numbers (not distinct).

I need to find out which numbers in table B col X do not exist in table A col X.  Help please!!!!!!  Thank you!
thedaveg155Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
thedaveg155Connect With a Mentor Author Commented:
Just figured it myself.  Thanks for the comment but it didn't work for me.

Either:
SELECT DISTINCT * FROM A
WHERE X Not In (SELECT DISTINCT X FROM B)
Or:
SELECT A.* FROM A
LEFT JOIN B on A.X = B.X
WHERE B.X Is Null
0
 
Helena Markováprogrammer-analystCommented:
This works in Oracle, I think you can change it if neccessary to  MS-SQL:

Select X from B
MINUS
Select X from A;
0
 
Helena Markováprogrammer-analystCommented:
You can ask 0-point question in a Community Support for refunding points :)
0
 
mlmccCommented:
This question has been answered by the asker.

mlmcc
DB Reporting Tools PE
0
All Courses

From novice to tech pro — start learning today.