ISNULL returns the first expression when it is not NULL; otherwise, it returns a replacement value. Its behavior and availability depend on the database system.
Missing values are common in business data. Replacing NULL values can make reports and calculations easier to understand.
Display zero when a sales value is missing.
SELECT
ProductName,
ISNULL(SalesAmount, 0) AS SalesAmount
FROM Sales;
ISNULL is useful for reports, calculations, data cleaning, and handling missing business values.
- ISNULL handles NULL values.
- It can provide a replacement value.
- It is commonly used in SQL Server.
- NULL handling is important in reporting.
- COALESCE is more portable.
What does ISNULL do?
ISNULL returns a replacement value when the supplied expression is NULL.
Is ISNULL the same in every database?
No. ISNULL is commonly associated with SQL Server, while other databases may use different NULL-handling functions.