SQL Server Performance

View ordered

Discussion in 'Getting Started' started by MihaiStoica, Sep 20, 2007.

  1. MihaiStoica New Member

    Hi everibody
    I am working with SQL Server Express. I have a view whose definition is something like this: SELECT ... FROM .. ORDER BY. If I am running the view (execute SQL) result is correct (orderly) but if I am opening the view, result it isn't (not orderly). Why ? What I have to do ?
    Thanks in advance
  2. thomas New Member

    Views cannot be ordered.. you have to

    SELECT cols FROM VIEW
    ORDER BY col
  3. FrankKalis Moderator

    Looks you're experiencing something like this: http://support.microsoft.com/default.aspx?scid=kb;en-us;926292
    Putting an ORDER BY clause inside a view definition has always been senseless. It is the SELECT statement which queries the view that requires the ORDER BY to enforce the guaranteed order. In SQL Server 2000 the ORDER BY from within the view was propagated to the outer SELECT, thus a statement like SELECT * FROM view appears to be sorted correctly. However, it was never guaranteed to, but just happens to be this way because of the implementation. In SQL Server 2005 this implementation has changed to follow the standard and now this is screwing up a lot of code.

Share This Page