Re: Help Needed - ISNULL when the field is already null..

From: Nicolas LeBlanc (nicolas_leblanc_at_nospamhotmail.com)
Date: 02/18/05


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.
> >
> >
>
>



Relevant Pages

  • Re: CRUD in SP or Dynamic SQL
    ... parsed and complied once (the first time it is executed). ... Dynamic SQL requires parsing and compiling on *every* execution. ... Also from a maintenance perspective - when you use stored procedures - you ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Centre Screen Browser Startup
    ... "rikesh" a écrit dans le message de ... > Is it possible to start the Browser in the centre screen, ... What are you calling "the first time"? ...
    (microsoft.public.inetsdk.html_authoring)
  • Re: Select into problem
    ... I have created a procedure that contains dynamic sql, ... The first time I launch the procedure it gives correct results. ... Do you rename or drop the #t table explicitly within the proc? ...
    (comp.databases.sybase)
  • Select into problem
    ... I have created a procedure that contains dynamic sql, ... their data types. ... The first time I launch the procedure it gives correct results. ...
    (comp.databases.sybase)