SQL Server COALESCE() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

SQL Server COALESCE() Function

❮ SQL Server Functions

Example

Return the first non-null expression in a list:

SELECT COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');
Try it Yourself »

Definition and Usage

The COALESCE() function returns the first non-null expression in a list.

Syntax

COALESCE(expr1, expr2, ...., expr_n)

Parameter Values

Parameter Description
expr1, expr2, expr_n Required. The expressions to test

Technical Details

Works in: SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

More Examples

Example

Return the first non-null expression in a list:

SELECT COALESCE(NULL, 1, 2, 'W3Schools.com');
Try it Yourself »

❮ SQL Server Functions