question

Bone12-2270 avatar image
0 Votes"
Bone12-2270 asked Viorel-1 edited

Case Statement - End with a Blank Value

Hi,

I have a Case Statement but to close it off, I have

else ' ' end as 'Variable_Name'

This then still outputs a 0 but I want it to be blank. Any idea how I can do this please?

sql-server-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

Try casting the expressions that appear before else, for example:

... then cast(Co_Numeric as varchar(max)) else ' ' end as 'Variable_Name'

Sometimes you can use NULL instead of ' '.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.