ISNULL Function [Miscellaneous]

Returns the value of the first non-NULL expression in the parameter list.

At least two expressions must be passed to the function.

Syntax

ISNULLexpression, expression [ …, expression ] )

Parameters

Parameters

Parameter

Description

expression

An expression to be tested against NULL.

Returns

The return type for this function depends on the expressions specified. That is, when the database server evaluates the function, it first searches for a data type in which all the expressions can be compared. When found, the database server compares the expressions and then returns the result in the type used for the comparison. If the database server cannot find a common comparison type, an error is returned.

Example

The following statement returns the value -66:

SELECT ISNULL( NULL ,-66, 55, 45, NULL, 16 ) FROM iq_dummy

Usage

The ISNULL function is the same as the COALESCE function.

Standards and Compatibility

  • SQL—Transact-SQL extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Related reference
COALESCE Function [Miscellaneous]