In this article I am going to explain how to show 0 instead of null value in sql server.
In previous article I have explained COALESCE function of sql server with example, Sql Server’s CASE expression and how to find difference between two dates inday, hour, minute and second using 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
Read this article: COALESCE function of sql server with example.
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.