Home All Groups Group Topic Archive Search About
Author
18 May 2006 8:43 PM
Justin
how do you deal with case null?

CASE @test WHEN NULL THEN ...........

Author
18 May 2006 8:48 PM
curtmorrisonemail@gmail.com
[columnname] =
    CASE
        WHEN [columnname] IS NULL THEN 'It's NULL'
        ELSE 'It's not NULL'
    END
Author
18 May 2006 8:50 PM
Tibor Karaszi
The expression implies:

CASE WHEN @test = NULL THEN...

And you probably know value = NULL evaluates to UNKNOWN which in turn (in most cases) evaluates to
FALSE. Here's how to do:

CASE WHEN @test IS NULL THEN...

So, use a searched case instead of a simple case.

Show quote
"Justin" <jus***@hotmail.com> wrote in message news:%23EpRzureGHA.4828@TK2MSFTNGP05.phx.gbl...
> how do you deal with case null?
>
> CASE @test WHEN NULL THEN ...........
>
Author
18 May 2006 8:51 PM
Vern Rabe
CASE
   WHEN @test IS NULL THEN...

HTH
Vern

Show quote
"Justin" wrote:

> how do you deal with case null?
>
> CASE @test WHEN NULL THEN ...........
>
>
>
Author
18 May 2006 9:54 PM
BurgerKING
for future reference...

null is not a value.  and it's a grave mistake to use it as such in the
database.  try to avoid inserting null in the database at all cost;
certain cases are unavoidable, however.

since it's not a value, you can't compare against it. ie. x = null.

AddThis Social Bookmark Button