Home

NULL should not be compared directly

Rule description

  • NULL should not be compared directly

 

Non-compliant Code Example

SELECT Product.ProductID,  
Product.Name,
Color  
FROM Production.Product  
WHERE ListPrice = NULL;  --Non compliant code (Column is directly compared with NULL)

Compliant Code Example

SELECT Product.ProductID,  
Product.Name,
Color  
FROM Production.Product  
WHERE ListPrice Is NULL;  --Compliant code
Visual Expert 2020
 VETSQLRULE17