C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

What is the result when comparing two nulls in SQL?


Posted Date: 19 Jul 2008    Resource Type: Articles    Category: Databases
Author: Gaurav AroraMember Level: Diamond    
Rating: 1 out of 5Points: 10



The answer is quite interesting 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'


For more details, visit http://stuff4mdesktop.blogspot.com/2008/07/what-is-result-when-comparing-two-nulls.html




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
SqlServer  .  Interviews  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: What is difference between Union and Union All?
Previous Resource: How to Insert Multiple Records Using Single Insert - SQL SERVER
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use