Re: Help Needed - ISNULL when the field is already null..
From: Nicolas LeBlanc (nicolas_leblanc_at_nospamhotmail.com)
Date: 02/18/05
- Next message: JM: "Re: USA states and cities?"
- Previous message: --CELKO--: "Re: USA states and cities?"
- In reply to: Sylvain Lafontaine: "Re: Help Needed - ISNULL when the field is already null.."
- Next in thread: Gert-Jan Strik: "Re: Help Needed - ISNULL when the field is already null.."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Feb 2005 14:03:36 -0500
Seems about right. I wonder why I didn't think of that one before...
I sure won't go into dynamic sql, no way!
Merci !
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> a
écrit dans le message de news:Ozl8y$dFFHA.3732@TK2MSFTNGP14.phx.gbl...
> Based on your needs, you must use one of the two following statements:
>
> Where (Field = @Field)
>
> Where @Field is Null OR (Field = @Field)
>
> Where (@Field is Null and Field is Null) OR (Field = @Field)
>
> Where (@Field is Null and Field is Not Null) OR (Field = @Field)
>
> There is also an option in SQL-Server that will make the equality (Null =
> Null) return True instead of False but I don't suggest using it; otherwise
> you will have a continuous moving target.
>
> S. L.
>
> "Nicolas LeBlanc" <nicolas_leblanc@nospamhotmail.com> wrote in message
> news:%23VrpzvdFFHA.3312@TK2MSFTNGP15.phx.gbl...
> > Hello,
> >
> > I just noticed today, after a long time, that if you do a
> >
> > SELECT * FROM Table WHERE Field = Field
> >
> > And that Field is null, it will return NOTHING at all...
> >
> > Problem is, in my search stored procedures, I always use:
> >
> > SELECT ... FROM Table WHERE Field = ISNULL(@Field, Field)
> >
> > So if the value is null, it simply avoid the check.
> >
> > But now I'm screwed, for the first time I have to do this on fields that
> > CAN
> > be null... and well, it returns NOTHING.
> >
> > of course, WHERE Field IS NULL works like a charm, but I need this to be
> > working so if it's null, it skips the filter, if not, it does it.
> >
> > Any help would be appreciated.
> >
> >
>
>
- Next message: JM: "Re: USA states and cities?"
- Previous message: --CELKO--: "Re: USA states and cities?"
- In reply to: Sylvain Lafontaine: "Re: Help Needed - ISNULL when the field is already null.."
- Next in thread: Gert-Jan Strik: "Re: Help Needed - ISNULL when the field is already null.."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|