IS NOT NULL condition in SQL Server
This SQL Server tutorial shows how to use the IS NOT NULL condition along with specific syntax and examples.
This SQL Server tutorial shows how to use the IS NOT NULL condition along with specific syntax and examples.
The IS NOT NULL condition in SQL Server is used to check if the value is NOT NULL. A NULL value in a table is a value in an empty field, in other words, a field with no value.
Syntax syntax IS NOT NULL
'expression' IS NOT NULL Variable name or variable value
Note
- The expression whose value NOT NULL is returned is TRUE
- The expression whose value NULL is returned is FALSE
For example - SELECT command
Example IS NOT NULL condition in SQL Server SELECT statement.
SELECT *
FROM nhanvien
WHERE ho IS NOT NULL;
This example returns all records from the user table whose employee information field contains no NULL values (not left blank).
Example - INSERT command
INSERT INTO danhba
(danhba_id, ho, ten)
SELECT nhanvien_id, ho, ten
FROM nhanvien
WHERE ho IS NOT NULL;
This command will insert the record into the namba table if the employee's last name in the table is not NULL.
Example - UPDATE command
UPDATE nhanvien
SET tinhtrang = 'Active'
WHERE ho IS NOT NULL;
The records in the table that have them are not NULL values will be updated.
Example - DELETE command
DELETE FROM nhanvien
WHERE tinhtrang IS NOT NULL;
In this example, all records from the table have a 'status' information field that does not contain a NULL value that will be deleted.
Previous article: IS NULL condition in SQL Server
Next article: Condition LIKE in SQL Server
Discover more
MS SQL Server SQL Server NULL mssqlShare by
David PacYou should read it
- How to Check for Null in Java
- NULL value in SQL
- Foreign Key with Set Null in SQL Server
- How to Check Null in Java
- What is / dev / null in Linux?
- The Quiet Details That Make a Sports Betting Platform Feel Reliable
- Instructions on creating toy set images with ChatGPT AI
- How are AI agents changing the journalism industry?
- Condition LIKE in SQL Server
- Conditions NOT in SQL Server
- ALIAS in SQL Server