The topic describes the DF049 T-SQL code analysis rule.
BEST PRACTICE
NULL is used in a comparison or expression.
Operations with the NULL literal can produce undesired results. It is recommended to use the IS [NOT] NULL or ISNULL/COALESCE function instead.
It is important to note that operations involving the NULL literal can lead to unexpected or undesired results in SQL queries. By using the IS [NOT] NULL condition or the ISNULL/COALESCE function, you can effectively handle NULL values in your queries and ensure consistent and predictable behavior, reducing the risk of errors or unexpected outcomes.
IF @Name = NULL
BEGIN
RAISERROR('Name is null',16,-1)
END
GO
IF @Name IS NULL
BEGIN
RAISERROR('Name is null',16,-1)
END
GO