SQL Server IS NOT NULL condition is used to test for a NOT NULL value.
expression IS NOT NULL
Parameter explanation
expression: It specifies the value to test where it is NOT NULL value.
Note: If the expression is NOT a NULL value, the condition evaluates to TRUE. If it is a NULL value, the condition evaluates to FALSE.
IS NOT NULL operator with SELECT Statement
Example:
Retrieve all employees from the table “Employees” where salary is NOT NULL value.
SELECT *
FROM [javatpoint].[dbo].[Employees]
WHERE salary IS NOT NULL;
Output:

IS NOT NULL operator with INSERT Statement
INSERT INTO [javatpoint].[dbo].[Employees]
(id, name, salary)
SELECT id, name, salary
FROM [javatpoint].[dbo].[Employee2]
WHERE name IS NOT NULL;
Output:

IS NOT NULL operator with UPDATE Statement
Update the employees of “Employees” table and set the name “Active” where name is not null.
UPDATE [javatpoint].[dbo].[Employees]
SET name = 'Active'
WHERE name IS NOT NULL;
Output:

Verify the example:

IS NOT NULL operator with DELETE Statement
Update the employees of “Employees” table where name is not null.
DELETE
FROM [javatpoint].[dbo].[Employees]
WHERE name IS NOT NULL;
Output:

Verify the example:

You can see that all employees are deleted from the table “Employees” where name is NOT NULL.
Leave a Reply