Id not in set gives no result Basically if I do the following:

SELECT distinct id FROM Table1


I get 20 000 rows

SELECT distinct id FROM Table1
WHERE id IN (SELECT id FROM Table2)


I get 4000 rows

So when I do the following, I expect to get 16000 rows, but I get no result.

SELECT distinct id FROM Table1
WHERE id NOT IN (select id from Table2)


-Empty result-

Why is this? Can it be that I run out of memory or something?
For NOT IN queries, it's safer to use NOT EXISTS if columns are NULLable, rather than try to handle NULLs with some additional logic. 

Here's a quick example script.

CREATE TABLE #t1 (Id INT NULL)

CREATE TABLE #t2 (Id INT NULL)

INSERT #t1 ( Id ) VALUES (1), (NULL), (3)

INSERT #t2 ( Id ) VALUES (1), (2), (NULL)

SELECT *
FROM #t1 AS t
WHERE t.Id NOT IN (SELECT t2.Id FROM #t2 AS t2)

SELECT *
FROM #t1 AS t
WHERE NOT EXISTS (SELECT * FROM #t2 AS t2 WHERE t2.Id = t.Id)

DROP TABLE #t1, #t2


Full disclosure: I do not work for either NOT IN Inc. or NOT EXISTS Corp.