Sql server : COALESCE function with example | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

Sql server : COALESCE function with example

Here in this article I am going to explain COALESCE function of sql server with example.

Description:
The COALESCE function takes comma separated list of arguments of same data type sbut returns the value of the first non-NULL argument.

Syntax:
COALESCE( expression1,[....n] )

 Example:
I have created a table Employee and insert some dummy data into it. 

Sql server  : COALESCE function with example

Now you can see in last 2 record status of employee is null. I want to replace null with 0. Run the below given query and check output.

select  name,COALESCE(Status,0) as 'status' from Employee

Output:

Sql server  : COALESCE function with example

  


Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget