Null Comparison on SQL Server Query Result

Hi,

Trying to do a ‘null’ comparison on a column returned from custom query. The query is set as ‘top 1’ so it returns 1 row always.

image

Output in console:
image

This condition is being returned as false. Not sure if this is a bug or I am doing something wrong.
Running this on localhost IIS & SQL Server.

I have tried:

  1. > 0 - Error: cannot convert Null to Double.
  2. ! - Error: cannot convert Null to Boolean.
  3. != null Returns true.
  4. == NULL Returns false.
  5. == 'null' Returns false.

Please help.

What server model are you using?

Forgot to mention server here. ASP.NET.

The correct way is to use == null. I will check with ASP.NET if perhaps it is a bug there.