Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
NullIf function in Sql server
WhatsApp
Gaurang Upadhyay
13y
4.4
k
0
0
25
Blog
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
Up Next
Split Function in Sql Server to break Comma-Separated Strings into Table
Ebook Download
View all
Basic SQL Queries
Read by 19.4k people
Download Now!
Learn
View all
Membership not found