Home Dashboard Directory Help
Search

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


Status: 

Closed
 as By Design Help for as By Design


1
0
Sign in
to vote
Type: Bug
ID: 588427
Opened: 8/23/2010 10:15:28 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

When running a query within parentheses with an ORDER BY clause, there is a failure of "Incorrect syntax near the keyword 'order'"
Details
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 http://blogs.msdn.com/b/tsql_language/archive/2004/09/23/233453.aspx

-Roman Kogan
SQL Language Team
Sign in to post a workaround.
Posted by Nathan-K on 8/23/2010 at 10:17 AM
Remove the parentheses from the query