Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Comparision Operators

Author  Topic 

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2014-09-12 : 04:41:42
Hi Team,

Script #1:
go
set ansi_nulls off
go
Declare
@var1 int =NULL,
@var2 int =NULL

if @var1 = @var2
print 'Null equals to Null is true'
else
print 'Null equals to Null is false'
go

Output:
Null equals to Null is true

Script #2:

go
set ansi_nulls off
go
Declare
@var1 int =NULL,
@var2 int =NULL

if @var1 >= @var2
print 'Null grater than or equals to Null is true'
else
print 'Null grater than or equals to Null is false'
go

Output:
Null grater than or equals to Null is false


When SET ANSI_NULLS OFF and both operands are NULL, (NULL=NULL) is true and (NULL>=NULL) is False.

How can we undersatnd the second condition (NULL>=NULL) this has to verify both > and = conditions,for Equal(=) it should return True?


M.MURALI kRISHNA

Arun Babu N
Starting Member

26 Posts

Posted - 2014-09-12 : 07:18:18
Nice Post..

Unlike the = (equality) comparison operator, the result of the >= comparison of two NULL values does not depend on the ANSI_NULLS setting

refer the link:

http://msdn.microsoft.com/en-us/library/ms181567.aspx

Arun Babu N
Go to Top of Page

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2014-09-16 : 09:01:32
Thanks Arun for Reply, it seems the statement is wrong in sql server 2000 documentation.

M.MURALI kRISHNA
Go to Top of Page

Arun Babu N
Starting Member

26 Posts

Posted - 2014-09-16 : 09:04:11
yes

arunbabu
Go to Top of Page
   

- Advertisement -