Incorrect syntax near the keyword 'order' when using parentheses - by Nathan-K

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 588427 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 8/23/2010 10:15:28 AM
Access Restriction Public


When running a query within parentheses with an ORDER BY clause, there is a failure of "Incorrect syntax near the keyword 'order'"
Sign in to post a comment.
Posted by Microsoft on 8/31/2010 at 3:45 PM
Dear Nathan-K,

This is by design. SELECT * FROM db is a query specification that can be used as either the top level in a relational stream, or somewhere in the middle, passing its selection on to another query specification. The SELECT * FROM db ORDER BY c1 can only be used as a top level select statement and not in the middle of a relational stream because ordering is not a relational operation.

By language convention, parentheses are permitted to delimit query specification (whose result must be relational), but not top level queries such as SELECT...ORDER BY.

See more at

-Roman Kogan
SQL Language Team