Skip to Content.
Sympa Menu

freetds - Re: select with NULL in where-clause doesnt work

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: select with NULL in where-clause doesnt work
  • Date: 11 Oct 2002 22:02:12 +0200


Il ven, 2002-10-11 alle 21:52, Hans Lang ha scritto:
> Hi,
>
> i am using freetds 0.60 with php 4.2.3 on Intel-Linux P4, 1.8Ghz.
> The SQL-Server is a MS SQL 7.0 Server, running on an PIII, 1Ghz.
>
> the problem i have is that i can't select records that have a NULL in a
> DATETIME-field.
>
> For example the value of "ausgeschieden", which is a DATETIME, in the
> record with ID=315 :
>
> 1> select ausgeschieden from personal_adresse where id=315
> 2> go
> ausgeschieden
> NULL
>
> this is fine, ID 315 isnt "ausgeschieden" yet.
>
> Looking up for that record results in an empty set:
> 1> select id from personal_adresse where ausgeschieden=NULL
> 2> go
>
> This is mysterious. Where is at least ID=315?
>

Is not misterous, is sql :)

try "select id from personal_adresse where ausgeschieden IS NULL"
=NULL is always false

> DATETIME's with Values behave as they should:
> 1> select count(ID) from personal_adresse where ausgeschieden<getdate();
> 2> go
>
> 197
>
> or
>
> 1> select id from personal_adresse where ausgeschieden>getdate();
> 2> go
> id
> 456
>
> or
>
> 1> select ID from personal_adresse where ausgeschieden='Mar 31 2001
> 12:00AM';
> 2> go
> ID
> 42
> 309
> 58
> 187
> 266
> 268
> 278
> 319
>
>
>
> so what the hell is wrong with those NULLs here?
> running the same selects with the sybase-libs does work. no wonder, they
> are obviously right.
>
> what can i do to make them run with freetds as well?
>

See documentation on ANSI_NULL on mssql manuals.

>
>
> hopefully,
> hans
>
freddy77






Archive powered by MHonArc 2.6.24.

Top of Page