COALESCE (TSQL Function)

Returns the first argument that is not NULL.

Syntax

COALESCE ( expression_1 [, ...expression_n] )

Arguments

expression_1 … expression_n
is a list of expressions of any type.

Return Types

Returns the type of the expression with the highest type precedence.

Examples

PRINT COALESCE(NULL, NULL, 100, 200, NULL, 300);
PRINT COALESCE(NULL, NULL, 'Hello', NULL, 'Goodbye');

The result is:

100
Hello