I want to use a computed bit column that will be true if another column in the table is not null. What's the correct formula for this?
HasLabel = computed column (bit)
Label = varchar NULL
The following formula does not validate. - what am I missing?
Formula for HasLabel = Label IS NOT NULL
A computed column must return a value, whereas you are just doing a comparison. Try this instead:
case when label is null then 0 else 1 end
SQL Server will not understand this as a non-NULLable column however. To handle that, change the computation to:
isnull(case when label IS NULL then 0 else 1 end, 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With