🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.databases.mssql-l
Article #234

Re: NULL versus IN (NULL) versus IS NULL

#234
From: Dan G
Date: Mon, 06 Sep 1999 00:00
96 lines
2991 bytes
Hi,

That's true. The story of this thread is use if it's possible "expression IS
[NOT] NULL" as ANSI92 compliant procedure.



Grzegorz Rymarz wrote in message <37D39029.3AD5DA9@hector.com.pl>...
>Hi Dan,
>behaviour of expressions containing nulls depends on current value of
>ANSI_NULLS session setting.
>If it is enabled nulls behave in the way you have noticed (SQL-92
>conformance!!).
>After switching it off, your queries will start to work according to
>your expectations...
>
>Regards,
>Grzegorz Rymarz
>
>
>
>Dan G wrote:
>
>> Hello all,
>>
>> Take a moment and read test the below puzzle (could be a good lesson
>> for
>> some of us).
>> Compare the results/performance (and query plans) and respond to the
>> questions:
>> Running on SQL 7 (SP1).
>>
>> -- case A) <> NULL examples.
>>
>> select
>> count (*)
>> from
>> pos
>> where
>> cntc_name<>NULL
>>
>> select
>> count (*)
>> from
>> pos
>> where
>> cntc_name NOT IN (NULL)
>>
>> select
>> count (*)
>> from
>> pos
>> where
>> cntc_name IS NOT NULL
>>
>> Questions:
>> A) why the execution plans are the same (same predicate) but the
>> results are
>> different (BTW last one is the correct one !).
>> MS SQL 7  shouldn't allow the first two if they give wrong results
>> ;-(.
>>
>> -- B) = NULL
>>
>> select
>> count (*)
>> from
>> pos
>> where
>> cntc_name=NULL
>>
>> select
>> count (*)
>> from
>> pos
>> where
>> cntc_name IN (NULL)
>>
>> select
>> count (*)
>> from
>> pos
>> where
>> cntc_name IS NULL
>>
>> Questions:
>> B) Same question as above + why the filtering is removed from the
>> execution
>> plan ?.
>>
>> All the best,
>>
>> Dan.
>
>
>
Technical Details
Message-ID: <7r06h6$dl8$1@pollux.ip-plus.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7qvuii$o43$1@pollux.ip-plus.net> <37D39029.3AD5DA9@hector.com.pl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f695,d81f9450cc844161
X-Google-Attributes: gid10f695,public
X-Google-Thread: 104de1,d81f9450cc844161
X-Google-Attributes: gid104de1,public
X-Google-Thread: f6611,d81f9450cc844161
X-Google-Attributes: gidf6611,public
X-Google-Thread: 109c00,d81f9450cc844161
X-Google-Attributes: gid109c00,public
X-Google-Thread: 11301e,d81f9450cc844161
X-Google-Attributes: gid11301e,public
X-Google-Thread: 107d2f,d81f9450cc844161
X-Google-Attributes: gid107d2f,public
From: "Dan G" <Gavrilescu.Daniel@pmintl.ch>
Subject: Re: NULL versus IN (NULL) versus IS NULL
Date: 1999/09/06
Message-ID: <7r06h6$dl8$1@pollux.ip-plus.net>
X-Deja-AN: 521629272
References: <7qvuii$o43$1@pollux.ip-plus.net> <37D39029.3AD5DA9@hector.com.pl>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
X-Complaints-To: news@ip-plus.net
X-Trace: pollux.ip-plus.net 936615270 13992 194.209.91.2 (6 Sep 1999 10:54:30 GMT)
Organization: Swisscom IP+ (post doesn't reflect views of Swisscom)
NNTP-Posting-Date: 6 Sep 1999 10:54:30 GMT
Newsgroups: bit.databases.mssql-l,comp.databases.ms-sqlserver,microsoft.public.sqlserver,microsoft.public.sqlserver.programming,microsoft.public.sqlserver.server,microsoft.public.sqlserver.workshop