Monday 27 January 2020

Various ways of replacing NULL

Hi All,

Hope you all are doing good.

In this article, we will know about various ways of replacing NULL value.
Replace NULL value using ISNULL function()
Example: SELECT ISNULL(NULL,'No Employee') as Employee

Replace NULL value using CASE statement
Example:
SELECT CASE
WHEN 'SUNEEL' IS NULL THEN
'No Employee'
ELSE
'Employee'
END as Employee

Replace NULL value using COALESCE() function
SELECT COALESCE(NULL, 'No Employee') as Employee

Use of COALESCE() function
COALESCE() returns the first Non NULL value of a column in each row.

Example: 
SELECT Id, COALESCE(FirstName, MiddleName, LastName) AS Name FROM tblCustomer

Keep reading!!

Enjoy!!

No comments:

Post a Comment

Intoduction to Flutter

Hi All, I hope every one is doing good In this article, we will know about the introduction of Flutter.