If you’re running a query in SQL Server, and you get the following error…
Msg 104, Level 16, State 1, Line 8
ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator.
…you should check your SQL statement – you’ve probably omitted a column from your SELECT
list.
As the error message implies, you’ll probably only see this error if you’re running a query that contains a UNION
, INTERSECT
or EXCEPT
operator.
Simply adding the column to your SELECT
list should fix the problem.