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 |
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2008-12-03 : 16:22:09
|
| I used a query to Load values from two tables based on matching column values - to another table.It is suppossed to get 100% rows from one of the tables to my new table.However, some rows are missing.I wanted to see which one's. and need your help on this. Here's my sample query used for the insert:INSERT INTO ABC(......) SELECT FROM X_INFO, Y_INFOWHERE X_ZONE = Y_ZONE AND X_PLOT = Y_PLOTThanks. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-12-03 : 16:34:49
|
ABC was your target table.X_INFO was your source table with 100% rows needed.Y_INFO was your second source table and there are some rows not matching to X_INFO.You have used an inner join and this has taken only matching rows of the two tables.Now you want to know which rows from X_INFO are not in ABC?Select * from X_INFO as X where not exists (select * from ABC where matching_column = X.matching_column)Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2008-12-03 : 17:00:22
|
| Thanks to both of you - Webfred, and Tara. It was very helpful.I was trying using not exists, but doing something wrong - resulting in bad data. |
 |
|
|
|
|
|