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 |
|
jackallan
Starting Member
2 Posts |
Posted - 2009-06-09 : 13:27:30
|
OK I'm perplexed by this...I just ran this query:SELECT COUNT(*) FROM Cases WHERE case_installtype IS NULLSELECT COUNT(*) FROM Cases WHERE NOT (case_installtype = 'CRMInstalled' OR case_installtype = '1')And got this result:-----------29018(1 row(s) affected)-----------28(1 row(s) affected)How is this possible!??!?  |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-09 : 13:36:07
|
| second case it ignores the null valued records altogether. that why you get only 28 rows. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-09 : 13:38:02
|
| null is not stored as a value internally. it just represents lack of a defined value |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-06-09 : 13:44:31
|
you need to explicitly check for NULL in the second statement likeSELECT COUNT(*) FROM Cases WHERE case_installtype NOT IN ('CRMInstalled' ,'1') OR case_installtype IS NULLquote: Originally posted by jackallan
OK I'm perplexed by this...I just ran this query:SELECT COUNT(*) FROM Cases WHERE case_installtype IS NULLSELECT COUNT(*) FROM Cases WHERE NOT (case_installtype = 'CRMInstalled' OR case_installtype = '1')And got this result:-----------29018(1 row(s) affected)-----------28(1 row(s) affected)How is this possible!??!? 
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-09 : 13:54:35
|
quote: Originally posted by vijayisonly you need to explicitly check for NULL in the second statement likeSELECT COUNT(*) FROM Cases WHERE case_installtype NOT IN ('CRMInstalled' ,'1') OR case_installtype IS NULLquote: Originally posted by jackallan
OK I'm perplexed by this...I just ran this query:SELECT COUNT(*) FROM Cases WHERE case_installtype IS NULLSELECT COUNT(*) FROM Cases WHERE NOT (case_installtype = 'CRMInstalled' OR case_installtype = '1')And got this result:-----------29018(1 row(s) affected)-----------28(1 row(s) affected)How is this possible!??!? 
unless you've set ANSI NULLs setting to OFF |
 |
|
|
jackallan
Starting Member
2 Posts |
Posted - 2009-06-10 : 04:28:48
|
Thanks guys! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|