What will be the output of below query?

Select * from employee_master where employee_code = null;

 Posted by vishalneeraj-24503 on 12/6/2013 | Category: Sql Server Interview questions | Views: 1941 | Points: 40
Answer:

It will NOT return any records.Because Equal(=) sign is a comparison operator used with string/integer/double/decimal or any other data-types BUT not with NULL values.

Because Null means no data or absence of data.
If we want to fetch rows,then we have to modify query as

Select * from employee_master where employee_code Is Null;

Then it will fetch record which have NULL values.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response