May 15, 2008 at 6:36 am
Comments posted to this topic are about the item Show content differences between two tables/views
October 16, 2008 at 1:47 am
Hi Douwe,
I am quite new to SQL and I have a need to create a table (TableD)which would contain contents of TableA that do not exist in TableC and combining with contents of TableB that do not exist in TableC. All the tables have same number of columns and also identical column names. Combination of column1,column2 and column3 would give a unique key identifier. TableC contains over 1,000,000 records while TableA and TableB about 2,000,000 and 4,000,000 respectively.
Appreciate if you or other SQL gurus out there can assist me with creating a script to achieve this.
Kind regards,
Chris
October 16, 2008 at 2:42 am
You could try,
select *
into D
from A
where not exists (select 'x' from C where C.key=A.key)
union
select *
into D
from B
where not exists (select 'x' from C where C.key=B.key)
July 5, 2009 at 2:18 am
Using the Except operator, the following query returns any distinct values from TableA that are not also found in TableB.
SELECT * FROM TableA EXCEPT SELECT * FROM TableB
You may also use union all to find differences from the one and the other side .... as follows:
SELECT * FROM TableA EXCEPT SELECT * FROM TableB
unoin all
SELECT * FROM TableB EXCEPT SELECT * FROM TableA
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply