NOT IN subquery fails when there are NULL-valued results
Sorry guys, I had no idea how to phrase this one, but I have the following in a where clause: person_id not in ( SELECT distinct person_id FROM protocol_application_log_devl pal WHERE pal.set_id = @set_id ) When the subquery returns no results, my whole select fails to return anything. To work around this, I replaced person_id in the subquery with isnull(person_id, '00000000-0000-0000-0000-000000000000') . It seems to work, but is there a better way to solve this? It is better to use NOT EXISTS anyway: WHERE NOT EXISTS( SELECT 1 FROM protocol_application_log_devl pal WHERE pal.person_id =