为变量赋值的 Select 语句不得与 data-retrieval 组合使用(不涉及数据检索)

A Select statement that assigns a value to a variable must not be combined with data-retrieval (No data retrieval involved)

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

上面的查询抛出了标题中所述的异常。如果我错了,请纠正我,但在我看来,上述声明中没有涉及数据检索?

您必须像这样将值分配给 @c

SELECT
    @a = flagA,
    @b = flagB,
    @c = (CASE WHEN flagC IS NULL THEN 0 ELSE 1 END)
FROM table