Here in this article I am going to explain COALESCE function of sql server with example.
The COALESCE function takes comma separated list of arguments of same data type sbut returns the value of the first non-NULL argument.
COALESCE( expression1,[....n] )
I have created a table Employee and insert some dummy data into it.
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
What do you think about this article?
If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.