SQL Server IS NULL Condition (Operator)
The SQL Server IS NULL operator is used to test for a NULL value.
Syntax:
Parameter explanation
expression: It specifies a value whether it is NULL.
Note:
- If the expression is NULL value then the condition evaluates to TRUE.
- If expression is not a NULL value, the condition evaluates to FALSE.
IS NULL Operator with SELECT Statement
Example:
Output:
IS NULL Operator with INSERT Statement
Example:
Output:
Note: This displays "0 rows affected" because there is no NULL value in name in the "Employees" table.
IS NULL Operator with UPDATE Statement
Example:
Update the salary of the employees in "Employees" table and set to 100000 where salary is NULL.
Output:
You can verify it by using SELECT query:
IS NULL Operator with DELETE Statement
Delete the employees from the "Employees" table where age is NULL.
Example:
Output:
You can verify it by using SELECT query:
You can see that there is no NULL value in age in the above table.
|