ORDER BY in a Sql Server 2008 view <p>we have a view in our database which has an ORDER BY in it. Now, I realize views generally don't order, because different people may use it for different things, and want it differently ordered. This view however is used for a <strong>VERY SPECIFIC</strong> use-case which demands a certain order. (It is team standings for a soccer league.)</p> <p>The database is Sql Server 2008 Express, v.10.0.1763.0 on a Windows Server 2003 R2 box.</p> <p>The view is defined as such: </p> <pre><code>CREATE VIEW season.CurrentStandingsOrdered AS SELECT TOP 100 PERCENT *, season.GetRanking(TEAMID) RANKING FROM season.CurrentStandings ORDER BY GENDER, TEAMYEAR, CODE, POINTS DESC, FORFEITS, GOALS_AGAINST, GOALS_FOR DESC, DIFFERENTIAL, RANKING </code></pre> <p>It returns: </p> <pre><code>GENDER, TEAMYEAR, CODE, TEAMID, CLUB, NAME, WINS, LOSSES, TIES, GOALS_FOR, GOALS_AGAINST, DIFFERENTIAL, POINTS, FORFEITS, RANKING </code></pre> <p>Now, when I run a <strong>SELECT</strong> against the view, it orders the results by <strong>GENDER, TEAMYEAR, CODE, TEAMID</strong>. Notice that it is ordering by <strong>TEAMID</strong> instead of <strong>POINTS</strong> as the order by clause specifies. </p> <p>However, if I copy the SQL statement and run it exactly as is in a new query window, it orders correctly as specified by the <strong>ORDER BY</strong> clause.</p>