I would like join two tables into 1 table that has one common column and I need to try and avoid all duplicates.
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
2010-07-14 19:28:51
He stated there is only one column in common, this sounds more like a join than a union.
Malfist
2010-07-14 19:30:06
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
2010-07-14 19:31:00
+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
2010-07-14 19:30:00