Feifei Zhang
Feifei Zhang

Reputation: 135

Datatype is money, how to replace 0 with empty in SQL?

Datatype of column1 is money, I would like to replace 0 with empty.

I have tried the following, but it still shows 0

CASE 
   WHEN column1 = 0 
      THEN '' 
      ELSE column1 
END

This is in SQL Server 2012.

Upvotes: 0

Views: 386

Answers (2)

Pac0
Pac0

Reputation: 23174

The column needs to be nullable, and then you can simply use NULL

CASE WHEN column1 = 0 THEN NULL ELSE column1 END

Upvotes: 0

Ferdinand Gaspar
Ferdinand Gaspar

Reputation: 2063

Use NULL instead

CASE WHEN column1 = 0 THEN NULL ELSE column1 END

Upvotes: 1

Related Questions