views:

31

answers:

3

I would like join two tables into 1 table that has one common column and I need to try and avoid all duplicates.

A: 

Perhaps you want a SELECT DISTINCT and a LEFT JOIN

Malfist
A: 

You can do a UNION and insert into the new table (note that you have to create the table first)

INSERT INTO NewTable

SELECT Column1
FROM FistTable

UNION 

SELECT Column2
FROM SecondTable
Raj More
He stated there is only one column in common, this sounds more like a join than a union.
Malfist
This would be my recommendation also. I use these all the time at work to join common sets of data while avoiding duplicates. Keep in mind that both selects will need the same number and types of columns if you go this route.
MattB
+1  A: 

look at this (new in SQL Server 2008): MERGE (Transact-SQL)

Performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found in the other table.

KM

related questions