0

I want to get NULL values instead of zero in my query.I put a condition where the varchar '0.0000' is not supposed to display along with NULL value. When the outcome comes, NULL is not displayed but 0.0000 is still showing there. Is there anyway i can convert that varchar to NULL so that the value is not displayed?

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325

2 Answers2

3

You can use NULLIF:

Returns a null value if the two specified expressions are equal.

SELECT NULLIF(Column, '0.0000') As Column
FROM dbo.TableName
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
1
select case when your_column = '0.0000' then null
            else your_column
       end as your_column
from your_table
juergen d
  • 201,996
  • 37
  • 293
  • 362