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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 NULL Hanlding in SQL

Author  Topic 

amarmano
Starting Member

3 Posts

Posted - 2005-07-12 : 04:10:11
In SQL, if i execute the below command,

if null=null
print 'true'
else
print 'false'

the result is "false", whereas if i execute,

if 4=4
print 'true'
else
print 'false'

the result is "true"

Could anyone explain, why does it behave differently and return 'false' when null is used


Regds,
Amar

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-12 : 04:14:31
When comparing to Null you should use is Null than = null
if null is null
print 'true'
else
print 'false'



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -