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)
 Alternate method for IS NOT NULL

Author  Topic 

cjjubb
Starting Member

5 Posts

Posted - 2008-06-25 : 06:50:19
Hi all

Is there an alternate method to check if a value IS NOT NULL using an equals sign

e.g.

WHERE value = NOT NULL (I know this doesn't work!)


I know this may seem like a strange question but I the reason I have for needing to do it this way is a long story.


Any help would be appreacited

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-25 : 06:51:27
WHERE ISNULL(value,somedefaultvalue) <> somedefaultvalue
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-25 : 10:07:44
WHERE value IS NOT NULL is the correct approach
Otherwise index maynot be used if defined on that column

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-25 : 10:16:24
If you change the default ANSI setting, you can write Col1 = NULL or Col1 <> NULL.



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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-25 : 10:24:38
quote:
Originally posted by Peso

If you change the default ANSI setting, you can write Col1 = NULL or Col1 <> NULL.



E 12°55'05.25"
N 56°04'39.16"



I wouldnt prefer doing that

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-25 : 10:25:37
If VALUE is an identity, you can also use

WHERE Value >= 0

to get all records NOT NULL. (and where value indeed is greater than or equal to zero)



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

- Advertisement -