|
1 | 1 | --- |
2 | 2 | title: "IS NULL (Transact-SQL)" |
3 | | -description: "IS NULL (Transact-SQL)" |
| 3 | +description: Determines whether a specified expression is null. |
4 | 4 | author: VanMSFT |
5 | 5 | ms.author: vanto |
6 | | -ms.date: "03/16/2017" |
| 6 | +ms.reviewer: randolphwest |
| 7 | +ms.date: 06/16/2025 |
7 | 8 | ms.service: sql |
8 | 9 | ms.subservice: t-sql |
9 | 10 | ms.topic: reference |
@@ -33,74 +34,89 @@ dev_langs: |
33 | 34 | monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric" |
34 | 35 | --- |
35 | 36 | # IS NULL (Transact-SQL) |
| 37 | + |
36 | 38 | [!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricse-FabricDW-FabricSQLDB](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw-fabricsqldb.md)] |
37 | 39 |
|
38 | | - Determines whether a specified expression is NULL. |
39 | | - |
40 | | - :::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) |
41 | | - |
42 | | -## Syntax |
43 | | - |
| 40 | +Determines whether a specified expression is `NULL`. |
| 41 | + |
| 42 | +:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) |
| 43 | + |
| 44 | +## Syntax |
| 45 | + |
44 | 46 | ```syntaxsql |
45 | | -expression IS [ NOT ] NULL |
46 | | -``` |
47 | | - |
| 47 | +expression IS [ NOT ] NULL |
| 48 | +``` |
| 49 | + |
48 | 50 | ## Arguments |
49 | | - *expression* |
50 | | - Is any valid [expression](../../t-sql/language-elements/expressions-transact-sql.md). |
51 | | - |
52 | | - NOT |
53 | | - 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. |
54 | | - |
55 | | -## Result Types |
56 | | - **Boolean** |
57 | | - |
58 | | -## Return Code Values |
59 | | - If the value of *expression* is NULL, IS NULL returns TRUE; otherwise, it returns FALSE. |
60 | | - |
61 | | - If the value of *expression* is NULL, IS NOT NULL returns FALSE; otherwise, it returns TRUE. |
62 | | - |
63 | | -## Remarks |
64 | | - 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. |
65 | | - |
66 | | -## Examples |
67 | | - 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`. |
68 | | - |
| 51 | + |
| 52 | +#### *expression* |
| 53 | + |
| 54 | +Any valid [expression](../language-elements/expressions-transact-sql.md). |
| 55 | + |
| 56 | +- `NOT` |
| 57 | + |
| 58 | + Specifies that the Boolean result is negated. The predicate reverses its return values, returning `TRUE` if the value isn't `NULL`, and `FALSE` if the value is `NULL`. |
| 59 | + |
| 60 | +## Return types |
| 61 | + |
| 62 | +**Boolean** |
| 63 | + |
| 64 | +## Return code values |
| 65 | + |
| 66 | +If the value of *expression* is `NULL`, `IS NULL` returns `TRUE`; otherwise, it returns `FALSE`. |
| 67 | + |
| 68 | +If the value of *expression* is `NULL`, `IS NOT NULL` returns `FALSE`; otherwise, it returns `TRUE`. |
| 69 | + |
| 70 | +## Remarks |
| 71 | + |
| 72 | +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`. |
| 73 | + |
| 74 | +## Examples |
| 75 | + |
| 76 | +[!INCLUDE [article-uses-adventureworks](../../includes/article-uses-adventureworks.md)] |
| 77 | + |
| 78 | +### A. Return the name and weight for all products |
| 79 | + |
| 80 | +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`. |
| 81 | + |
69 | 82 | ```sql |
70 | | -USE AdventureWorks2022; |
71 | | -GO |
72 | | -SELECT Name, Weight, Color |
73 | | -FROM Production.Product |
74 | | -WHERE Weight < 10.00 OR Color IS NULL |
75 | | -ORDER BY Name; |
76 | | -GO |
77 | | -``` |
78 | | - |
79 | | -## Examples: [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)] |
80 | | - The following example returns the full names of all employees with middle initials. |
81 | | - |
| 83 | +SELECT Name, |
| 84 | + Weight, |
| 85 | + Color |
| 86 | +FROM Production.Product |
| 87 | +WHERE Weight < 10.00 |
| 88 | + OR Color IS NULL |
| 89 | +ORDER BY Name; |
| 90 | +GO |
| 91 | +``` |
| 92 | + |
| 93 | +## Examples: Azure Synapse Analytics and Analytics Platform System (PDW) |
| 94 | + |
| 95 | +### B. Return the full names of all employees with initials |
| 96 | + |
| 97 | +The following example returns the full names of all employees with middle initials. |
| 98 | + |
82 | 99 | ```sql |
83 | | --- Uses AdventureWorks |
84 | | - |
85 | | -SELECT FirstName, LastName, MiddleName |
86 | | -FROM DIMEmployee |
87 | | -WHERE MiddleName IS NOT NULL |
88 | | -ORDER BY LastName DESC; |
89 | | -``` |
90 | | - |
91 | | -## See Also |
92 | | - [CASE (Transact-SQL)](../../t-sql/language-elements/case-transact-sql.md) |
93 | | - [CREATE PROCEDURE (Transact-SQL)](../../t-sql/statements/create-procedure-transact-sql.md) |
94 | | - [CREATE TABLE (Transact-SQL)](../../t-sql/statements/create-table-transact-sql.md) |
95 | | - [Data Types (Transact-SQL)](../../t-sql/data-types/data-types-transact-sql.md) |
96 | | - [Expressions (Transact-SQL)](../../t-sql/language-elements/expressions-transact-sql.md) |
97 | | - [INSERT (Transact-SQL)](../../t-sql/statements/insert-transact-sql.md) |
98 | | - [LIKE (Transact-SQL)](../../t-sql/language-elements/like-transact-sql.md) |
99 | | - [Operators (Transact-SQL)](../../t-sql/language-elements/operators-transact-sql.md) |
100 | | - [Logical Operators (Transact-SQL)](../../t-sql/language-elements/logical-operators-transact-sql.md) |
101 | | - [SELECT (Transact-SQL)](../../t-sql/queries/select-transact-sql.md) |
102 | | - [sp_help (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-help-transact-sql.md) |
103 | | - [UPDATE (Transact-SQL)](../../t-sql/queries/update-transact-sql.md) |
104 | | - [WHERE (Transact-SQL)](../../t-sql/queries/where-transact-sql.md) |
105 | | - |
106 | | - |
| 100 | +SELECT FirstName, |
| 101 | + LastName, |
| 102 | + MiddleName |
| 103 | +FROM DIMEmployee |
| 104 | +WHERE MiddleName IS NOT NULL |
| 105 | +ORDER BY LastName DESC; |
| 106 | +``` |
| 107 | + |
| 108 | +## Related content |
| 109 | + |
| 110 | +- [CASE (Transact-SQL)](../language-elements/case-transact-sql.md) |
| 111 | +- [CREATE PROCEDURE (Transact-SQL)](../statements/create-procedure-transact-sql.md) |
| 112 | +- [CREATE TABLE (Transact-SQL)](../statements/create-table-transact-sql.md) |
| 113 | +- [Data types (Transact-SQL)](../data-types/data-types-transact-sql.md) |
| 114 | +- [Expressions (Transact-SQL)](../language-elements/expressions-transact-sql.md) |
| 115 | +- [INSERT (Transact-SQL)](../statements/insert-transact-sql.md) |
| 116 | +- [LIKE (Transact-SQL)](../language-elements/like-transact-sql.md) |
| 117 | +- [Operators (Transact-SQL)](../language-elements/operators-transact-sql.md) |
| 118 | +- [Logical Operators (Transact-SQL)](../language-elements/logical-operators-transact-sql.md) |
| 119 | +- [SELECT (Transact-SQL)](select-transact-sql.md) |
| 120 | +- [sp_help](../../relational-databases/system-stored-procedures/sp-help-transact-sql.md) |
| 121 | +- [UPDATE (Transact-SQL)](update-transact-sql.md) |
| 122 | +- [WHERE (Transact-SQL)](where-transact-sql.md) |
0 commit comments