Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
SQL database in Microsoft Fabric
Negates a Boolean input.
Transact-SQL syntax conventions
[ NOT ] boolean_expression
boolean_expression
Is any valid Boolean expression.
Boolean
NOT reverses the value of any Boolean expression.
Using NOT negates an expression.
The following table shows the results of comparing TRUE and FALSE values using the NOT operator.
NOT | |
---|---|
TRUE | FALSE |
FALSE | TRUE |
UNKNOWN | UNKNOWN |
The following example finds all Silver colored bicycles that do not have a standard price over $400.
-- Uses AdventureWorks
SELECT ProductID, Name, Color, StandardCost
FROM Production.Product
WHERE ProductNumber LIKE 'BK-%' AND Color = 'Silver' AND NOT StandardCost > 400;
GO
Here's the result set.
ProductID Name Color StandardCost
--------- ------------------- ------ ------------
984 Mountain-500 Silver, 40 Silver 308.2179
985 Mountain-500 Silver, 42 Silver 308.2179
986 Mountain-500 Silver, 44 Silver 308.2179
987 Mountain-500 Silver, 48 Silver 308.2179
988 Mountain-500 Silver, 52 Silver 308.2179
(6 row(s) affected)
The following example restricts results to SalesOrderNumber
to values starting with SO6
and ProductKeys
greater than or equal to 400.
-- Uses AdventureWorks
SELECT ProductKey, CustomerKey, OrderDateKey, ShipDateKey
FROM FactInternetSales
WHERE SalesOrderNumber LIKE 'SO6%' AND NOT ProductKey < 400;
Expressions (Transact-SQL)
Built-in Functions (Transact-SQL)
Operators (Transact-SQL)
SELECT (Transact-SQL)
WHERE (Transact-SQL)
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today