Why does EXCEPT not work? Incorrect syntax next to Word Except

SELECT SKU
FROM PartProductSupplemental
EXCEPT
SELECT SKU
FROM Inventory

Why am I getting this error:

Invalid syntax next to Word Except

I am checking the string and syntax is correct syntax:

SELECT ProductID 
FROM Production.WorkOrder
EXCEPT
SELECT ProductID 
FROM Production.Product
+5
source share
3 answers

Database compatibility mode is probably set to 2000 (80) or earlier.

In Management Studio:

  • Right-click the database name in the Databases heading in Object Explorer
  • In the "Properties" window that appears, select "Parameters" - the compatibility level takes third place from the top, to the right.
+8
source

MINUS .

, , ?

( 2005 , , () ).

0

When I run the following, it works fine:

with PartProductSupplemental as
(
  SELECT 1 sku
  UNION
  select 2
  UNION
  SELECT 3
  UNION
  select 4
  UNION 
  SELECT 5
),
Inventory as
(
  SELECT 1 sku
  UNION
  select 2
  UNION
  SELECT 3

)

SELECT SKU
FROM PartProductSupplemental
EXCEPT
SELECT SKU
FROM Inventory

Are you sure this is actually what you are using? Is there any sql over this?

0
source

All Articles