set ansi_nulls off
go
create table T (
i int
)
insert into T values (1)
insert into T values (null)
go
declare @null int
set @null = cast(@null as int)
select 0, i, 'not (i = null)' from T where not (i = null)
union all
select 1, i, 'not (1 = i)' from T where not (1 = i)
union all
select 2, i, 'not (i <> null)' from T where not (i <> null)
union all
select 3, i, '-i = null' from T where -i = null
union all
select 4, i, 'i = -null' from T where i = -null
union all
select 5, i, 'i in (-null)' from T where i in (-null)
union all
select 6, i, '= @null' from T where i = @null
union all
select 7, i, '= cast(@null as int)' from T where i = cast(@null as int)
union all
select 8, i, 'i = i' from T where i = i
union all
select 9, i, 'i <> i' from T where i <> i
union all
select 10, i, 'i <> null' from T where i <> null
union all
select 11, i, '<= null' from T where i <= null
union all
select 12, i, 'null = null' from T where null = null
order by 1, 2
go
drop table T
Steve Kass
Drew University
(ok, I ran it!)
Regards,
Greg Linwood
"Steve Kass" <sk...@drew.edu> wrote in message
news:uhuu1IIvCHA.2876@TK2MSFTNGP09...
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Steve Kass" <sk...@drew.edu> wrote in message
news:uhuu1IIvCHA.2876@TK2MSFTNGP09...
Steve Kass <sk...@drew.edu> wrote in message news:<uhuu1IIvCHA.2876@TK2MSFTNGP09>...
Steve
--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
select * from T
where i = NULL
Is this illegal in SQL-92 or 99 ?
SK
It works with variables though:
DECLARE @a varchar(4)
PRINT coalesce(@a, 'null')
SET ansi_nulls off
IF @a = @a
print 'equal'
else print 'not equal'
SET ANSI_NULLS OFF should mean: all NULLs are created equal and identical,
which as you have proved isn't the case in SQL 2000 and
SET ANSI_NULLS ON should mean: all NULLs are different from each other,
which is true in most cases in SQL 2000, but as there is only one NULL
allowed in a UNIQUE index, that's not totally true either....
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Steve Kass" <sk...@drew.edu> wrote in message
news:Orp8sQLvCHA.2124@TK2MSFTNGP11...
I think ANSI_NULLS OFF is very restricted in its scope, and only
should change the behavior when comparing a table column to the
unadulterated literal NULL with the specific operators = or <>..
But it's obviously a bad idea to put energy into the question "What is
the correct non-standard behavior?"
SK
I think the whole ANSI_NULLS option should be removed in the next version,
but MS will probably keep it in for backward compatibility. (Although...
they did a decent job with removing a lot of old rubbish from VB.NET, so you
never know).
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Steve Kass" <sk...@drew.edu> wrote in message
news:#3nZUpLvCHA.440@TK2MSFTNGP12...
No problem that I can see.
I get table T with one and NULL in it. I apply the predicate which
returns UNKNOWN for both rows. The * resolved to the single column i in
the SELECT. There are no rows that tested TRUE, so you get back an
empty result set.
The following works in Ocelot:
select * from T where i = cast(NULL as int)
SK
That is what I get for not having SQL-92 documents on my new XP laptop.
I also found that it is a bitch to move files to this thing, too, but
that is another story ...
You really should move your "files" using a single set-based INSERT.
You're
probably moving them one at a time with non-portable floppy diskettes, as if
nothing has changed in the last 20 years! ;)
SK
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Steve Kass" <sk...@drew.edu> wrote in message news:OLrodaMvCHA.2380@TK2MSFTNGP11...
"Alejandro Mesa" <Alejan...@GardensAmerica.com> wrote in message news:u0aPzMWvCHA.2288@TK2MSFTNGP09...
"Alejandro Mesa" <Alejan...@GardensAmerica.com> wrote in message news:u#HY97WvCHA.2504@TK2MSFTNGP10...
"Alejandro Mesa" <Alejan...@GardensAmerica.com> wrote in message news:u0aPzMWvCHA.2288@TK2MSFTNGP09...
Regards
Ryan
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm