Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Union and Order By in a View

 
   Database Help (Home) -> MSEQ RSS
Next:  Full Text Search Result  
Author Message
Stan G.

External


Since: Oct 17, 2008
Posts: 5



(Msg. 1) Posted: Mon Dec 01, 2008 7:54 am
Post subject: Union and Order By in a View
Archived from groups: microsoft>public>sqlserver>mseq (more info?)

I have coded a view that uses a Union and an Order By. When I execute the
query by itself, it works fine. When I select * from the View, even though
the full result set is returned, the results are not returned in the order
specified in the Order By.
Also, when I attempt to modify the View, I get a message window that says
"Unable to parse query text". I click OK and it opens the Query Designer
just fine.

 >> Stay informed about: Union and Order By in a View 
Back to top
Login to vote
Russell Fields

External


Since: Jan 10, 2008
Posts: 608



(Msg. 2) Posted: Mon Dec 01, 2008 11:35 am
Post subject: Re: Union and Order By in a View [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Stan,

The reason is as described in this link for SQL Server 2005 (and still true
in 2008):
http://msdn.microsoft.com/en-us/library/ms187956(SQL.90).aspx
The ORDER BY clause does not guarantee ordered results when the view is
queried, unless ORDER BY is also specified in the query itself.

The Designers in SQL Server Management Studio have several problems.
Generally, it is wiser (safer) to edit the script yourself. That way you
stay in full control of what happens.

RLF


"Stan G." wrote in message

>I have coded a view that uses a Union and an Order By. When I execute the
> query by itself, it works fine. When I select * from the View, even
> though
> the full result set is returned, the results are not returned in the order
> specified in the Order By.
> Also, when I attempt to modify the View, I get a message window that says
> "Unable to parse query text". I click OK and it opens the Query Designer
> just fine.

 >> Stay informed about: Union and Order By in a View 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
index on a view - Hello, I have a table (TAB) and A View with alias (VIEW) Table cod varchar 3 descr carchar 60 my view cod alias COd1 descr alias DES Now i need a index on view with key COD1 I can't create it. Can..

Creating an alias - I have an alias that can get very long because it maintains a information of where it came from. Is there a way to alias an alias? My first thought was: Declare @T1 varchar(128) Set T1 = 'MyAlias' .... Inner Join Table1 as @T1 This of course does no...

Formatting numeric fields in select-clause - This is propably a very simple question, but I can“t seem to find the answer to it in the documentation. I want to format a numeric field so the result is right justified and zero-filled. ex select 1 will give the result 01 How do I manage this..

Simple Query problem - Sample table as follows Order ID Stock Code Status --------- ------- ------- 203 STK1 3 203 STK2 2 203 STK4 3 204 STK1 3 204 STK5 3 205 ..

query assistance -return most recent date - I have a table that has two fields, pkg_num, which is a number, and del_date_time, which is a date-time. The table can contain duplicate pkg_num values, as long as the del_date_time values are different for any given number. I need a query that will...
   Database Help (Home) -> MSEQ All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]