SQL Interview: 21: Using ISNULL vs COALESCE

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Development Level: Medium
Question:
When writing T-SQL code, you often need to replace NULL values. The core two functions provided are ISNULL and COALESCE.
What is the difference between them?
Answer:
ISNULL only takes a single value to check and replaces it when NULL.
COALESCE takes a list of values and returns the first non-NULL value.
Another key difference is the returned data type. ISNULL returns the data type of the first parameter. COALESCE returns the data type of the value with the highest precedence.
2025-02-15