DECLARE @a bit;
DECLARE @b bit;
DECLARE @c bit;
SELECT
@a = flagA, @b = flagB,
CASE WHEN flagC is null then @c = 0 ELSE @c = 1 END
FROM Table
上面的查询会抛出标题中所述的异常。如果我错了,请纠正我,但在我看来,上述陈述中没有涉及数据检索?
答案 0 :(得分:1)
您必须将值分配给@c
,如下所示:
SELECT
@a = flagA,
@b = flagB,
@c = (CASE WHEN flagC IS NULL THEN 0 ELSE 1 END)
FROM table