| title | <> (Not Equal To) (Transact-SQL) | ||
|---|---|---|---|
| description | Compares two expressions and returns TRUE if the left operand isn't equal to the right operand. | ||
| author | rwestMSFT | ||
| ms.author | randolphwest | ||
| ms.date | 05/07/2026 | ||
| ms.service | sql | ||
| ms.subservice | t-sql | ||
| ms.topic | reference | ||
| ms.custom |
|
||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric || =fabric-sqldb |
[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw-fabricsqldb]
Compares two expressions (a comparison operator). When you compare non-null expressions, the result is TRUE if the left operand isn't equal to the right operand. Otherwise, the result is FALSE. If either or both operands are NULL, see SET ANSI_NULLS.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
expression <> expression
Any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.
Boolean
[!INCLUDE article-uses-adventureworks]
The following example returns all rows in the Production.ProductCategory table that don't have a value in ProductCategoryID that equals 3 or 2.
SELECT ProductCategoryID,
Name
FROM Production.ProductCategory
WHERE ProductCategoryID <> 3
AND ProductCategoryID <> 2;[!INCLUDE ssResult]
ProductCategoryID Name
------------------ ----------------------
1 Bikes
4 Accessories