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

Alex Celeste
  • 12,824
  • 10
  • 46
  • 89
Vimal Patel
  • 2,785
  • 2
  • 24
  • 38

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
  • 977
  • 8
  • 17