What is COALESCE Function in SQL Server?
COALESCE FUNCTION
Definition
Return the first NON NULL value in a list.
Syntax
COALESCE(expr1, expr2,…,expr n)
Example
SELECT
COALESCE(NULL,NULL,'GOSWAMI') AS NAME
SELECT
COALESCE('RAM',NULL,NULL) AS NAME
SELECT
COALESCE(NULL,'MANOHAR',NULL) AS NAME
SELECT
COALESCE('HARISH','KUMAR','RAWAT') AS NAME
Output
Note: it returns always first non-null value.
Comments
Post a Comment