Why case when [A] is null then 'NULL' else [A] end as [A] does not work?

Hello

Any idea why the below does not work?

select
case when [A] is null then 'NULL' else [A] end as [A]
from [Table1]

Thanks!

Can you define what "does not work" mean, with sample data

What data type is A? If it's some type of numeric, you can't mix string -- 'NULL' -- and numeric.

1 Like
select
case when [A] is null then 'NULL' else convert(varchar(100),[A]) end as [A]
from [Table1]
1 Like

Thanks, it should really pop up an error or something!
@yosiasz it didn't work by not inserting 'null' when null but unfortunately I think I lost the field I was running this against so cannot confirm it if was numberic.