Introduction:

In this article we will explain how to use NULL Function in SQL Server OR what is NULL Function in SQL Server with Example.

Description:

The SQL NULL is the term used to represent a missing or unknown value. A NULL value in a table is a value in a column that appears to be blank. A column with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces.

Following is an example of student table:

select s.Id,s.Name,s.Mobile,s.address1 as
[Address], f.amount as Fee from
Student s left join Fee f on s.id=f.StudentId

Result:

How to use  NULL in sql


SQL IS NULL: 

Let's see the query to get all the records where value is NULL:

select s.Id,s.Name,s.Mobile,s.address1 as
[Address], f.amount as Fee from
Student s left join Fee f on s.id=f.StudentId where f.amount NULL

Result:

How to use  NULL in sql


SQL IS NOT NULL:

Let's see the query to get all the records where value is NOT NULL

select s.Id,s.Name,s.Mobile,s.address1 as
[Address], f.amount as Fee from
Student s left join Fee f on s.id=f.StudentId where f.amount IS NOT NULL

Result:

How to use  NULL in sql


I hope this article will help to you.


0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like