[dba-SQLServer] Order of data in views

jwcolby jwcolby at colbyconsulting.com
Tue May 13 14:17:50 CDT 2008


In the past I created a set of count views.  For months I have been 
opening a query window and entering

SELECT * FROM SomeView.

The order of the fields was always ordered, now it is not.

Someone a while back made a comment something like "a view is by its 
nature unsorted".  Why this would be I haven't a clue since there are 
order by criteria right in the view, but be that as it may, this has 
worked in the past and now it is not.

The issue here is that the client expects to see the data sorted.  So 
now I have to go do something like:

SELECT * FROM SomeView Order BY SomeField

And voila, sorted data.  The issue of course is that it is no longer 
simple.  I gave to discover the name of the order by field and enter 
that in my query window.

Any ideas why it did work and now does not?  How to make it just take 
the order of the underlying view and pass it through?

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-SQLServer mailing list