Posts

Showing posts with the label What is SQL Server COALESCE() Function

What is COALESCE Function in SQL Server?

Image
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.