Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
View with union and order by returns error
Message
From
30/01/2004 12:11:30
 
 
To
30/01/2004 05:47:15
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00872222
Message ID:
00872396
Views:
21
I get an syntax error near 'order' when I include the parentheses (which are unnecessary) - not sure why it doesn't give an syntax error running the select statement alone...
Also, ORDER BY is invalid in views, so you'll need to remove that as well as the parentheses for the view to be created.


>CREATE View MyView AS
> Select * from MyTable1
> Union (Select * from MyTable2)
> Where ...
>Order by myField1,myField2
>
>The Enterprise Manager view designer says it can't deal with that sort of thing, order or no order, Union queries are not supported, although it does process the query and, as far as I can determine, return the correct results.
>
>The Query Analyzer on the other hand does not complain on syntax check, but refuses to compile and save the view with an error near Order By.
>
>Selecting the text and pressing F5 will execute the query without any problem.
>
>What the heck is going on here, and how does one get around this behavior?
>
>TIA
>
>Peter
>TIA
>
>Peter
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform