The topic describes the DF085 T-SQL code analysis rule.
STYLE
The CASE statement is used without the ELSE clause.
It is recommended to add the ELSE clause to the CASE expression with either a default action, or a comment explaining the reason an action is not taken.
Using a CASE statement without the ELSE clause can lead to unexpected results or NULL values when none of the specified conditions are met, potentially causing errors or undesired behavior in queries.
SELECT
CASE
WHEN @id = 12 THEN 'YES'
END
SELECT
CASE
WHEN @id = 12 THEN 'YES'
ELSE NULL
END