COALESCE Function in TSQL

Raj
Raj
Member
496 Points
21 Posts

Hi,

What does mean by COALESCE? When and how we can use it in T-SQL?

 

Thanks...

Views: 8899
Total Answered: 1
Total Marked As Answer: 0
Posted On: 02-May-2016 02:20

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Teacher
4822 Points
23 Posts
         

Evaluates the arguments in order in which they are putted and returns the first non-NULL expression value. If all expression have NULL value then it will return NULL.

Syntax:

COALESCE ( expression [ ,...n ] ) 

-- Azure SQL Data Warehouse and Parallel Data Warehouse

COALESCE ( expression [ ,...n ] )

Example: 

SELECT Name, Class, Color, ProductNumber,
COALESCE(Class, Color, ProductNumber) AS FirstNotNull
FROM MyProduct;

 

Posted On: 04-May-2016 19:08
 Log In to Chat