NOT

Transact-SQL Reference

Transact-SQL Reference

NOT

Negates a Boolean input.

Syntax

[ NOT ] boolean_expression

Arguments

boolean_expression

Is any valid Microsoft® SQL Server™ Boolean expression.

Result Types

Boolean

Result Value

NOT reverses the value of any Boolean expression.

Remarks

The use of NOT negates an expression.

This table shows the results of comparing TRUE and FALSE values using the NOT operator.

  NOT
TRUE FALSE
FALSE TRUE
UNKNOWN UNKNOWN
Examples

This example finds all business and psychology books that do not have an advance over $5,500.

USE pubs
GO
SELECT title_id, type, advance
FROM titles
WHERE (type = 'business' OR type = 'psychology')
   AND NOT advance > $5500
ORDER BY title_id ASC
GO

Here is the result set:

title_id type         advance               
-------- ------------ --------------------- 
BU1032   business     5000.0000
BU1111   business     5000.0000
BU7832   business     5000.0000
PS2091   psychology   2275.0000
PS3333   psychology   2000.0000
PS7777   psychology   4000.0000

(6 row(s) affected)

See Also

Expressions

Functions

Operators (Logical Operators)

SELECT

WHERE