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 |
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2007-11-19 : 15:50:26
|
| How to find the rows in one table that are not in another?I have two tables NewColors and OldColors. Both tables have a column named Color.NewColors has 4 rows Black Blue Red GreenOldColors has 5 rows Black Tan Pink Red Orange GreenI need to identify that “Blue” is missing from OldColors when compared to NewColors. Then add it as a new row to OldColors. The way I was going to approach this is to full join the two tables together. Then append to OldColors the row that does not have a match. But I am thinking there had got to be a better way, simpler way. What is the correct way to do this? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-11-19 : 15:59:15
|
| select * from Table1 t1where not exists (select * from Table2 t2 where t2.SomeColumn = t1.SomeColumn)Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2007-11-19 : 16:07:36
|
Thank you. I knew there had to be a better way. |
 |
|
|
|
|
|