Will one of these do the trick?
select * from <table> where ((column is null) or (column = value))
select * from <table> where isnull(column, value) = value
kevin_g_frey@hotmail.com (Kevin Frey) wrote in message news:<e5d907ad.0404042246.2d000353@posting.google. com>...
> Hello,
>
> I have a table which contains some nullable columns. I want to write a
> single query, which can be prepared (ie. prepared statement), that can
> handle null or non-null values for the where clause. Is this possible
> in a standard-conforming manner?
>
> The simple for of the query is this:
>
> SELECT * FROM <table> WHERE <column> = <value>
>
> But when the value to be matched on is NULL, the syntax of the query
> must change to be:
>
> SELECT * FROM <table> WHERE <column> IS <value>
>
> In the second case <value> is NULL.
>
> I know one option might be to change the ANSI NULL handling option,
> but I am loathe to do this (I have five RDBMS's to support, not just
> MSSSQL).
>
> I thought I might have been able to cheat using an IN clause to make
> the SQL consistent, but no luck.
>
> Thanks
>
> Kevin