Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pras2007
Posting Yak Master
216 Posts |
Posted - 2009-10-16 : 06:23:22
|
| Hello All,I have two tables that I'm joinning by a "full outer join". The goal is to insert records that does not exist in table_A with values from Table_b, does anyone know how to accomplish this task?CREATE TABLE [dbo].[Table_A]( [ID] [int] IDENTITY(1,1) NOT NULL, [COL1] [nchar](10) NULL, [COL2] [nchar](10) NULL, [COL3] [nchar](10) NULL) ON [PRIMARY]CREATE TABLE [dbo].[Table_B]( [ID] [int] IDENTITY(1,1) NOT NULL, [COL1] [nchar](10) NULL, [COL2] [nchar](10) NULL, [COL3] [nchar](10) NULL) ON [PRIMARY]SELECT A.ID, A.COL1, A.COL2, A.COL3, B.COL1 AS B_COL1, B.COL2 AS B_COL2, B.COL3 AS B_COL3FROM Table_4 A FULL OUTER JOIN Table_5 B ON A.ID = B.IDPlease advice |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2009-10-16 : 07:00:33
|
| INSERT INTO Table_A (COL1,COL2,COL3)SELECT COL1,COL2,COL3 FROM Table_B WHERE ID NOT IN (SELECT ID FROM Table_A) |
 |
|
|
|
|
|
|
|