NullIf function in Sql server

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.