I’m experiencing something strange, and I can’t understand why this is not working; even though it should be quite simple.
Let’s say I have a query that selects into a temp table like this:
SELECT customer_no
INTO #temp
FROM #old_temp
One temp that selects from another temp and it works. Customer_no is varchar(6). I have only one value for testing purposes: ‘123456’
Then the code is trying to do this:
SELECT customer_no
FROM #temp
WHERE customer_no NOT IN
(SELECT cust_number from AnotherCustomerTable)
In AnotherCustomerTable, ‘123456’ doesn’t exist fore sure. And the customer_no is also varchar(6). What ever I try, I result is empty, while I should get ‘123456’ in result set.
Anyone who have experienced this, and know what it could be? I tried trim functions but that didn’t help.
Solved!
Stupid me didn’t consider the NULLs in the sub select. Added this: