Why does this..
DECLARE @SkyBlue Bit
SET @SkyBlue = 1
IF @SkyBlue
Select 'the sky is blue!'
ELSE
Select 'the sky is not blue!'
Produce this
"An expression of non-boolean type specified in a context where a condition is expected, near 'Select'."
And is there a Boolean type in SQL2008?
@SkyBlue is a bit, not a boolean. Try:
DECLARE @SkyBlue Bit
SET @SkyBlue = 1
IF @SkyBlue = 1
Select 'the sky is blue!'
ELSE
Select 'the sky is not blue!'
Note that this also fails
if 1
Select 'the sky is blue!'
ELSE
Select 'the sky is not blue!'
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