Last updated 6 years ago
Was this helpful?
Look at the following "Products" table:
Suppose that the "UnitsOnOrder" column is optional, and may contain NULL values.
Look at the following SELECT statement:
SELECT ProductName, UnitPrice * (UnitsInStock + UnitsOnOrder) FROM Products;
In the example above, if any of the "UnitsOnOrder" values are NULL, the result will be NULL.
SELECT ProductName, UnitPrice * (UnitsInStock + ISNULL(UnitsOnOrder, 0)) FROM Products
The SQL Server function lets you return an alternative value when an expression is NULL: