Export (0) Print
Expand All

EXCEPT

Returns a collection of any distinct values from the query expression to the left of the EXCEPT operand that are not also returned from the query expression to the right of the EXCEPT operand. All expressions must be of the same type or of a common base or derived type as expression.

expression EXCEPT expression

expression
Any valid query expression that returns a collection to compare with the collection returned from another query expression.

A collection of the same type or of a common base or derived type as expression.

EXCEPT is one of the Entity SQL set operators. All Entity SQL set operators are evaluated from left to right. The following table shows the precedence of the Entity SQL set operators.

 

Precedence Operators

Highest

INTERSECT

 

UNION

UNION ALL

 

EXCEPT

Lowest

EXISTS

OVERLAPS

FLATTEN

SET

The following Entity SQL query uses the EXCEPT operator to return a collection of any distinct values from two query expressions. The query is based on the AdventureWorks Sales Model. To compile and run this query, follow these steps:

  1. Follow the procedure in How to: Execute a Query that Returns StructuralType Results.

  2. Pass the following query as an argument to the ExecuteStructuralTypeQuery method:


(SELECT product from AdventureWorksEntities.Products as product
WHERE product.ListPrice  > @price1 ) except
(select product from AdventureWorksEntities.Products as product
WHERE product.ListPrice > @price2)
    




Build Date:

2012-10-01
Show:
© 2014 Microsoft