Skip to content
Advertisement

MS SQL handling null values same as strange string

I have a view V_BaseData_Extract in MS SQL server with one column Comments having null values as well having other textual values too. Column type is nvarcahr.

What’s happening is that SQL returning same count for both below mentioned queries.

First Query:

select count(*)
  from V_BaseData_Extract where Comments 
  not in  ( '                                                                                                                                                                                               ' , '                                                                                                                               
                                                                  ')    

Second Query:

  select count(1) from V_BaseData_Extract a where a.Comments is not null 

Its handling null same as the string mentioned in my first query’s where condition. What could be the reason behind that ? Am I missing something ?

Is null equivalent to some number of blank spaces ?

Advertisement

Answer

This is the correct explanation. Comments above helped me look into right direction and search relevant terms.

NULL values inside NOT IN clause

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement