TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
NullIf function in Sql server
Gaurang Upadhyay
Feb 02, 2012
4.4
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Use of Isnull function and nullif
Step 1: Create Table
Create Table Test1 ( ClientName varchar(50),Price varchar(50))
Step 2: Insert Value
Insert INTO Test1 Values('Gaurang','')
Insert INTO Test1 Values('Jinal',null)
Insert INTO Test1 Values('Brijesh',null)
Insert INTO Test1 Values('Atit','')
Insert INTO Test1 Values('Viral',null)
Insert INTO Test1 Values('Bhavnesh','')
Step 3: Run above Query
Select * From Test1
In this result price column have blank and null value
Step 4: Run above Query
Select ClientName, Isnull(Price,'0.0') From test1
From the above query only null value replace with '0.0'
So you have to use other way :
Select ClientName, Isnull(nullif(Price,''),'0.0') From test1
Now run above query you will get exactly '0.0 ' in Price column
NULLIF Function
: Returns a null value if the two specified expressions are equivalent.
------------------------------------
Thanks & Regards
Gaurang Upadhyay
Sr Developer.
NullIf function in Sql server
Next Recommended Reading
Split Function in Sql Server to break Comma-Separated Strings into Table