Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Why are nulls not being returned?

Author  Topic 

nismo
Starting Member

3 Posts

Posted - 2008-04-29 : 23:11:19
Select * from table where field <> 'This'


Why does that not return nulls? 'This' does not equal null. Why does sql server work this way?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-30 : 02:30:47
NULL means unknown value.
And since you are SELECTing all records where Field is not equal to "This" NULL obviously can't be fetched, because you don't know their values. It is unknown, or a better word "undetermined".

Select * from table where coalesc(field, 'x') <> 'This'



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-30 : 03:02:25
quote:
Originally posted by nismo

Select * from table where field <> 'This'


Why does that not return nulls? 'This' does not equal null. Why does sql server work this way?


NULL is not stored as a value. Its actually set as an internal bit to indicate unknown value. So it wont be fetched using above condition.
Go to Top of Page
   

- Advertisement -