DF185: ELSE NULL is used in CASE expression.
Last modified: December 25, 2024
The topic describes the DF185 T-SQL code analysis rule.
Category
BEST PRACTICE
Message
ELSE NULL is used in CASE expression.
Description
It is recommended to omit the ELSE NULL statement in the CASE expression as it will still return NULL as default value.
Noncompliant code example
SELECT CASE WHEN Qty < 10 THEN 'Low' ELSE NULL END AS prt_level
FROM dbo.Storage
GO
Compliant solution
SELECT CASE WHEN Qty < 10 THEN 'Low' END AS prt_level
FROM dbo.Storage
GO
Was this page helpful?