On Thu, 2004-04-29 at 23:20, Chuck Fox wrote:
> Hmmm,
> 
> So column != column when the column contains a null.  How very unusual.  
> I would have assumed that null = null, but there I go assuming things 
> again. 
> 
> So why does this work ?
> 
> create table foo( i int, c char(10) null )
> go
> insert foo values( 1, null )
> insert foo values( 2, "2" )
> go
>  
> select * from foo where c = null
> go
> declare @c char(10)
> select @c = null
> select * from foo where c = isnull( @c, c )
> go

If you are using Sybase then the default behavior is to allow comparison
to NULL. This is NOT ANSI SQL compliant, and one should use "where foo
is NULL" instead of "where foo = NULL" to be on the safe side.

This behavior is controlled by the ANSINULL option - see the SET T-SQL
command.

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
[EMAIL PROTECTED]                       http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html


Reply via email to