为什么这样做..
DECLARE @SkyBlue Bit
SET @SkyBlue = 1
IF @SkyBlue
Select 'the sky is blue!'
ELSE
Select 'the sky is not blue!'
制作本
“非布尔类型的表达式 在上下文中指定的 条件是预期的,靠近'选择'。“
SQL2008中是否有布尔类型?
答案 0 :(得分:13)
@SkyBlue有点,不是布尔值。尝试:
DECLARE @SkyBlue Bit
SET @SkyBlue = 1
IF @SkyBlue = 1
Select 'the sky is blue!'
ELSE
Select 'the sky is not blue!'
请注意,这也失败了
if 1
Select 'the sky is blue!'
ELSE
Select 'the sky is not blue!'