[dba-SQLServer] Views don't sort

jwcolby jwcolby at colbyconsulting.com
Fri May 20 18:00:39 CDT 2011


I understand that.  Unfortunately to do it "the safe way" means that it has to be done by the Jet 
engine on the workstation.  That means back to all of the index pulls etc.

John W. Colby
www.ColbyConsulting.com

On 5/20/2011 4:47 PM, Stuart McLachlan wrote:
> Be careful with that. It is not guaranteed to work!
>
> See http://msdn.microsoft.com/en-us/library/ms188385.aspx
> <quote>
> The ORDER BY clause is not valid in views, inline functions, derived tables, and subqueries,
> unless TOP is also specified.
> ...
> When ORDER BY is used in the definition of a view, inline function, derived table, or
> subquery, the clause is used only to determine the rows returned by the TOP clause. The
> ORDER BY clause does not guarantee ordered results when these constructs are queried,
> unless ORDER BY is also specified in the query itself
> </quote>
>
> The only way to be sure is to use "Select * from vwMyView Order by colMyCol"
>



More information about the dba-SQLServer mailing list