In this post explains how to use the ISNULL function in SQL Server (Transact-SQL) with syntax and examples.
In SQL Server (Transact-SQL), the ISNULL function lets you return an alternative value when an expression is NULL.
The syntax for the ISNULL function in SQL Server (Transact-SQL) is:
ISNULL( expression, alternative_value )
The value to test whether it is NULL.
The value to return if the expression is a NULL value.
The ISNULL function can be used in the following versions of SQL Server (Transact-SQL):
Let's look at some SQL Server ISNULL function examples and explore how to use the ISNULL function in SQL Server (Transact-SQL).
For example:
SELECT ISNULL(NULL, 'AODBA.com');
Output: 'AODBA.com'
SELECT ISNULL('mySite.com', 'AODBA.com');
Output: 'mySite.com'
SELECT ISNULL(NULL, 45);
Output: 45
SELECT ISNULL(12, 45);
Output: 12
SELECT ISNULL(NULL, '2014-05-01');
Output: '2014-05-01'
SELECT ISNULL('2014-04-30', '2014-05-01');
Output: '2014-04-30'