I was debugging a stored procedure the other day and found some logic something like this:
SELECT something
FROM someTable
WHERE idcode <> (SELECT ids FROM tmpIdTable)
This returned nothing. I thought it looked a little odd with the "<>" so I changed it to "NOT IN" and then everything worked fine. I was wondering why this is? This is a pretty old proc and I am not really sure how long the issue has been around, but we recently switched from SQL Server 2005 to SQL Server 2008 when this was discovered. What is the real difference between "<>" and "NOT IN" and has the behavior changed between Server2005 and 2008?
WHERE idcode NOT IN (...)
is equivalent toWHERE idcode <> ALL (...)
– Kong