SQL Server Handle NULL value in Where Clause

Sometime you have to select values from your SQL Server table if record has null value or not. For example I have below table in design mode and with records.


Image 1.


Image 2.

Now Write Query to Select All records

  1. SELECT * FROM EMPLOYEE  

Image 3.

Now if you want to fetch those records who have EXPERIENCE as null. You will want to write your query like below.
  1. SELECT * FROM EMPLOYEE WHERE EXPERIENCE = NULL  
  2. SELECT * FROM EMPLOYEE WHERE EXPERIENCE = 0  
  3. SELECT * FROM EMPLOYEE WHERE EXPERIENCE < 1  

Image 4.

Now write your query like below.
  1. SELECT * FROM EMPLOYEE WHERE EXPERIENCE IS NULL  

Image 5.
  1. SELECT * FROM EMPLOYEE WHERE ISNULL(EXPERIENCE,0)=0  

Image 6.

Now query to select All records where Experience is Not Null
  1. SELECT * FROM EMPLOYEE WHERE EXPERIENCE IS NOT NULL  

Image 7.