1

I have 2 tables (stud and stud1). Both having 2 columns but stud1 contains 1 record which is null.

data from query

I have created following 2 queries.First one is returning the accurate result but other one which is using not in returning nothing. I guess that is because of the null value. But I don't understand the reason for it. Can someone help me with this?

enter image description here

Leushenko
  • 12,217
  • 9
  • 48
  • 85
Vimal Patel
  • 2,103
  • 2
  • 21
  • 36

1 Answers1

0

See NOT IN clause and NULL values.

That's because your 2nd query equals:

SELECT * FROM #stud
WHERE ID <> NULL

When ansi_nulls is on, ID <> NULL is unknown, so you won't get any rows.

Community
  • 1
  • 1
zhongxiao37
  • 917
  • 7
  • 16