what is the diffrence between Null and IsNull?

Posted by Udaysimha under Sql Server on 1/19/2012 | Points: 10 | Views : 5782 | Status : [Member] | Replies : 6
Hi All,
Please let me know the difference between Null and Isnull.
Thanks

uday


Responses

Posted by: Blessyjees on: 1/19/2012 [Member] Bronze | Points: 25

Up
0
Down

Hi,

Null means that the empty of value and isnull is used to check the value is null or not and isnull is using with where clause

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanthlaxmi on: 1/19/2012 [Member] Starter | Points: 25

Up
0
Down
= NULL is always unknown (this is piece of 3 state logic), but WHERE clause treats it as false and drops from the result set. So for NULL you should use IS NULL

Reasons are described here: http://stackoverflow.com/questions/1843451/why-does-null-null-evaluate-to-false-in-sql-server


If this helps you .
Please "Mark as Answer"

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Niladri.biswas on: 2/8/2012 [Member] Platinum | Points: 25

Up
0
Down
Null is value whose presence is being check with Is Null

Declare @input varchar(10) = NULL

Select
Case When @input IS NULL Then 'Null Present' Else 'Not Null'
End As Result


Result
Null Present


Also there is a function call ISNULL which checks if NULL is present or not and if so replaces the NULL value with the default value being supplied
Declare @input varchar(10) = NULL

Select ISNULL(@input,'Default value') As Result


Result
Defalt value


Best Regards,
Niladri Biswas

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/20/2012 [Member] Bronze | Points: 25

Up
0
Down
NULL

NULL is supposed to be undefined, meaning you don't know what it could be. "" on the other hand is actually defining it is as
something; a blank value.

ISNULL
If your database is initializing the fields as "", then = NULL is the right way. If you use the keyword NULL, then ISNULL will correctly test for it.

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 6/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Null means assign Null values .ISNull means check null or not


Regards

sriram

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kirthiga on: 6/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

NULL means Empty or blank value.

ISNULL is a built-in function used to assign some values for NULL

For Example
select ISNULL(NULL,100)

Replace NULL into 100

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response