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.
| Author |
Topic |
|
shawnmolloy
Yak Posting Veteran
93 Posts |
Posted - 2008-11-08 : 04:54:23
|
| I want to filter by columns that are not null. This doesn't work for me:SELECT * FROM [mytable] where price = nullThanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-08 : 04:56:20
|
| SELECT * FROM [mytable] where price IS NULL |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-08 : 05:01:07
|
| The reason why equality operators like =,<>,>,.. wont work with NULL is because NULL is not internally as a value. NULL just designates lack of value i.e NULL = NULL is also not true. thats why under default settings equality operators wont work with NULL.However you can override this property by changing ANSI NULL settings. by running belowSET ANSI NULLS OFFyou specify SQL Server to regard NULL as value in which case you can use queries like above to return NULL values.See books online for more detailshttp://doc.ddart.net/mssql/sql70/set-set_5.htm |
 |
|
|
shawnmolloy
Yak Posting Veteran
93 Posts |
Posted - 2008-11-08 : 05:03:52
|
| Oh yeah, that's right. IS NULL, not = NULL. I always get that mixed up :PThanks! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-08 : 05:06:10
|
Welcome |
 |
|
|
|
|
|