Skip to content

Latest commit

 

History

History
106 lines (88 loc) · 3.95 KB

is-null-transact-sql.md

File metadata and controls

106 lines (88 loc) · 3.95 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom f1_keywords helpviewer_keywords dev_langs monikerRange
IS NULL (Transact-SQL)
IS NULL (Transact-SQL)
VanMSFT
vanto
03/16/2017
sql
t-sql
reference
ignite-2024
NULL_TSQL
IS_[NOT]_NULL_TSQL
IS_NULL_TSQL
NULL
[NOT]_TSQL
IS
IS_TSQL
IS NULL
IS [NOT] NULL
[NOT]
verifying nullability
IS NOT NULL clause
null values [SQL Server], verifying
null values [SQL Server], IS [NOT] NULL
IS [NOT] NULL clause
testing nullability
checking nullability
TSQL
>=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

IS NULL (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-FabricDW-FabricSQLDB]

Determines whether a specified expression is NULL.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

expression IS [ NOT ] NULL  

Arguments

expression
Is any valid expression.

NOT
Specifies that the Boolean result be negated. The predicate reverses its return values, returning TRUE if the value is not NULL, and FALSE if the value is NULL.

Result Types

Boolean

Return Code Values

If the value of expression is NULL, IS NULL returns TRUE; otherwise, it returns FALSE.

If the value of expression is NULL, IS NOT NULL returns FALSE; otherwise, it returns TRUE.

Remarks

To determine whether an expression is NULL, use IS NULL or IS NOT NULL instead of comparison operators (such as = or !=). Comparison operators return UNKNOWN when either or both arguments are NULL.

Examples

The following example returns the name and the weight for all products for which either the weight is less than 10 pounds or the color is unknown, or NULL.

USE AdventureWorks2022;  
GO  
SELECT Name, Weight, Color  
FROM Production.Product  
WHERE Weight < 10.00 OR Color IS NULL  
ORDER BY Name;  
GO  

Examples: [!INCLUDEssazuresynapse-md] and [!INCLUDEssPDW]

The following example returns the full names of all employees with middle initials.

-- Uses AdventureWorks  
  
SELECT FirstName, LastName, MiddleName  
FROM DIMEmployee  
WHERE MiddleName IS NOT NULL  
ORDER BY LastName DESC;  

See Also

CASE (Transact-SQL)
CREATE PROCEDURE (Transact-SQL)
CREATE TABLE (Transact-SQL)
Data Types (Transact-SQL)
Expressions (Transact-SQL)
INSERT (Transact-SQL)
LIKE (Transact-SQL)
Operators (Transact-SQL)
Logical Operators (Transact-SQL)
SELECT (Transact-SQL)
sp_help (Transact-SQL)
UPDATE (Transact-SQL)
WHERE (Transact-SQL)