Difference between Column_name Is Null and Column_name = Null in Sql-server

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 1022
Hi,today we will see what is the Difference between Column_name Is Null and Column_name = Null in Sql-server?

Null means the absence of value i.e. no data.

Suppose,we have Employee_Master table,which contains 25 rows and some column has a NULL value.

Employee Master contains Id,Name and Address columns and 7 rows as shown

Id      Name    Address
1 Vishal Pune
2 Neeraj NULL
3 Nitin Nagpur
4 Rajesh Jodhpur
5 Pooja Nagpur
6 Praveen Bhilai
7 Vinod NULL

As we can see,Address column has 2 null values.
Here are the cases,now we can understand what's difference.

Case -1. Select * From Employee_Master Where Address Is Null;

Id Name Address
2 Neeraj NULL
7 Vinod NULL

Case -2. Select * From Employee_Master Where Address = Null;

Id Name Address


As we can see,if we write Address Is Null in the query then it will populate 2 records which are Null,but when we write Address = Null,then it will not produce any rows.

Because Null means no data or absence of data.So when column having null value use Column is null instead of column = null.

Because Equal(=) operator is an assignment as well as comparison operator which is applicable only for string,integer,double and so on but not with NULL.

Comments or Responses

Login to post response