Sql server : Show 0 instead of null value - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Sql server : Show 0 instead of null value

In this article I am going to explain how to show 0 instead of null value in sql server.

We have three alternatives to show 0 instead of null value in Sql.

1st alternate: ISNULL
Sql’s Isnull function is used to replace null with specified replacement value.


Select id,Name,Phone, ISNULL(salary,0) as [Salary] from Employee

2nd alternate: CASE
Check this article : CASE expression in Sql Server.

Select id,Name,Phone, case when salary IS NULL then 0 else salary end as [Salary] from Employee
3rd alternate: COALESCE

Select id,Name,Phone, COALESCE(salary,0) as [Salary] 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.

Share this

Share on FacebookTweet on TwitterPlus on Google+