Reputation: 3345
I would like join two tables into 1 table that has one common column and I need to try and avoid all duplicates.
Upvotes: 1
Views: 4876
Reputation: 11
Hope this will help
MERGE <target_table> [AS TARGET]
USING <table_source> [AS SOURCE]
ON <search_condition>
[WHEN MATCHED
THEN <merge_matched> ]
[WHEN NOT MATCHED [BY TARGET]
THEN <merge_not_matched> ]
[WHEN NOT MATCHED BY SOURCE
THEN <merge_ matched> ];
Upvotes: 0
Reputation: 103587
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.
Upvotes: 2
Reputation: 48016
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
Upvotes: 0