February 1, 2017 at 11:27 am
I have two tables
table 1 and table 2 i want to select distinct records from both these tables and load into main table.
How to write the query?
February 1, 2017 at 11:31 am
Do all the tables have an identical structure? Doing a UNION removes all duplicates from a dataset so...INSERT INTO MainTable
SELECT *
FROM Table1
UNION
SELECT *
FROM Table2;
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
February 1, 2017 at 11:39 am
Yes, all 3 tables has same structure.
we are having 2 packages, in one package we are loading table 1 data in another package we are loading table 2 data.
but we are planning to call package 2 in package1..so that they will be as one. and in last state planning to load from these two tables into main table.
in both these table1 and table 2 there may be some duplicates.. that's why planning to do distinct..is that works? or the way which you mentioned using union works?
February 1, 2017 at 11:45 am
Yes the union will work, just the union without a union all will do a distinct on the entire result set.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply