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
Image 3.
Now if you want to fetch those records who have EXPERIENCE as null. You will want to write your query like below.
- SELECT * FROM EMPLOYEE WHERE EXPERIENCE = NULL
- SELECT * FROM EMPLOYEE WHERE EXPERIENCE = 0
- SELECT * FROM EMPLOYEE WHERE EXPERIENCE < 1
Image 4.
Now write your query like below.
- SELECT * FROM EMPLOYEE WHERE EXPERIENCE IS NULL
Image 5.
- SELECT * FROM EMPLOYEE WHERE ISNULL(EXPERIENCE,0)=0
Image 6.
Now query to select All records where Experience is Not Null
- SELECT * FROM EMPLOYEE WHERE EXPERIENCE IS NOT NULL
Image 7.