Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

When To Use the Order By Clause - (whenever ordering is required) Expand / Collapse
Posted Wednesday, July 7, 2004 6:25 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, November 12, 2008 10:24 AM
Points: 31, Visits: 24

The conclusions of the article* may be a bit misleading:

1 "We do not require an "order by" clause in a table, which has got a clustered index." 2 "We do not require an "order by" clause for a non-index column in a select statement and both index and non-index column in a select statement."

The Order By clause itself is indeed optional, and more often than not 1 & 2 may indeed be observed in practice, However: Ordered results are only guaranteed if an order by is included. That is 1 & 2 are reproducible in the scope of the given examples and in many but not necessarily all situations. In other words the behavior represents an implementation artifact rather than a design property and should be kept in mind if considering omitting Order By in any non-trivial application that actually requires specific ordering). {IOW do so at your own risk.}  HTH


Post #125084
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse