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 |
|
goligol
Posting Yak Master
128 Posts |
Posted - 2011-10-12 : 12:34:54
|
| HiI am trying to find the records "hs_code" of a table which are not existing in another tableSelect distinct hs_code from legacy.exp_mo where hs_code not in (select hs from dev.hs2naics8_export)but it happens that there is only one record of "hs_code" which is also in "hs" in dev.hs2naics8_export remain in the above query.any suggestion! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-10-12 : 12:39:02
|
| Not sure what you are saying is wrong.What do you expect and what do you get.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
rajarajan
Starting Member
48 Posts |
Posted - 2011-10-12 : 12:39:36
|
| remove the distinct from the query Select hs_code from legacy.exp_mo where hs_code not in (select hs from dev.hs2naics8_export) |
 |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2011-10-12 : 12:42:47
|
| You should not use NOT IN unless you understand 3 value logic.Use NOT EXISTS or LEFT JOIN instead.In your case the table dev.hs2naics8_export must have at least one NULL for the column hs. |
 |
|
|
goligol
Posting Yak Master
128 Posts |
Posted - 2011-10-12 : 12:53:30
|
| Thank you, thank you, thank you |
 |
|
|
|
|
|