Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Operator RSS Feeds

Not Operator

Posted By: Sarita Patel     Category: SQL Server     Views: 1868

This article describes the use of Not operator in sql server with different examples.

Not operator negates a boolean input. The use of NOT negates an expression.

 


Syntax of  NOT Operator :

[ NOT ] boolean_expression


boolean_expression is valid boolean expression in sql server.

Return type of Not operator is Boolean. Not reverses the value of any boolean expression.

Below table shows the truth table of NOT operator.

NOT

TRUE

FALSE

FALSE

TRUE

UNKNOWN

UNKNOWN

 



Examples of NOT Operator :

 

Example 1 : Using NOT operator in where clause

SELECT ProductName,UnitPrice

FROM   Products

WHERE  NOT ProductName LIKE 'a%'

 

Output

ProductName                                  UnitPrice

Chai                                                   18.00

Chang                                                19.00

Chef Anton's Cajun Seasoning        22.00

Chef Anton's Gumbo Mix                21.35

Grandma's Boysenberry Spread       25.00

Uncle Bob's Organic Dried Pears   30.00

Northwoods Cranberry Sauce          40.00

 

Above query returns product name not starting with character ‘a’, as expression is negated by NOT operator. 

  
Share: 


Didn't find what you were looking for? Find more on Not Operator Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of Not Operator is from United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!