How to use IS NULL in SQL Server for checking the Null value?

Asked 14-Sep-2021
Viewed 705 times

1 Answer


0

SQL NULL Values :
In a database table if a column field has NULL value it means that field has no value.
When a new record in inserted in table and a column is optional and we don’t insert value in that column field then that field will saved with NULL value.
Test for NULL Values :
NULL values can not be test by comparison operators(=,>,<,<>). We can use ‘IS NULL’ and ‘IS NOT NULL’ operators for check the NULL values.
Syntax-
SELECT column1,column2,cloumn3,…. FROM tablename WHERE column IS NULL/ IS NOT NULL;
Lets we have a table 'StudentData' 
                        How to use IS NULL in SQL Server for checking the Null value?
Syntax- SELECT column1, column2,... FROM table_name WHERE column IS NULL/ IS NOT NULL
Check for IS NULL values :
Here we check the null value in the field in StudentData table.
        select stuAge, stuName, stuCourse from StudentData where stuCourse is null;
                        How to use IS NULL in SQL Server for checking the Null value?
Check for IS NOT NULL values :
        select stuAge, stuName, stuCourse from StudentData where stuCourse is not null;
                How to use IS NULL in SQL Server for checking the Null value?