What is the result, when NULL is compared with NULL?

Answer Posted / gaurav arora

The answer-6 is quite matching with my stuff. Let me clear
it in more writting:
1. When we compare two nulls then the result
always 'false'. The main reason is the null is not a value
its neither an empty nor a empty space, so the actual
result is null which places as null.
2. When we compare a null with another which has some value
like some int value then the result is false. The actual
result is false and not null.

Consider the following examples:

--null = null is null which is false
Declare @intNull1 int
Set @intNull1 =null
Declare @intNull2 int
Set @intNull2=null
If @intNull1=@intNull2
Print 'null = null is true'
Else
Print 'null = null is false'

--Now assign some value
Set @intNull1 = 1
If @intNull1=@intNull2
Print 'null = int value is true'
Else
Print 'null = int value is false'

Thanks,
Gaurav Arora
http://stuff4mdesktop.blogspot.com/

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is execute immediate?

720


Why do we create views in sql?

780


what are the advantages and disadvantages of views in a database? : Sql dba

765


What are the rules to be applied to nulls whilst doing comparisons?

984


How do I count rows in sql query?

690






What is the difference between the sql*loader and import utilities? : aql loader

758


What do you know by pl/sql cursors?

759


Which command is used to delete a package?

773


What is a primary key called that is made up of more than one field?

1029


What is primary key secondary key alternate key candidate key?

765


What is the use of pl/sql table?

758


what is sql profiler? : Sql dba

793


What is the difference between local and global temporary table?

756


what is a trigger? : Sql dba

762


How is debugging done?

723