Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
View not respecting ORDER BY clause
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01348243
Message ID:
01413949
Vues:
59
Starting with SQL 2005 the ORDER BY clause in a view does not guaranteed any particular order. From BOL 2005
"In SQL Server 2005, the ORDER BY clause in a view definition is used only to determine the rows that are returned by the TOP clause. The ORDER BY clause does not guarantee ordered results when the view is queried, unless ORDER BY is also specified in the query itself".

>
>Got a weird one here. I create a *simple* view in the SQL 2005 View Designer:
>
>SELECT ALL
>guiUniqueID, chvCollectionKey, chvCaption, chvClassLibrary,
>chvClassName, chvParentNode, inyNodeLevel, insNodeSequence, 
>inyNodePlacement, bitExternalProcess, dtmCreated, chvCreator, dtmUpdated, chvUpdater
>FROM Control.TreeViewNodes
>ORDER BY inyNodeLevel, insNodeSequence
>
>When I execute the code in the View Designer, all is well. However, when I execute the view from either a query or by right-clicking the view name and choosing Open View, the ORDER BY clause does not function correctly. I get the correct quantity and selection of rows that I expect -- they're just not in the correct order.
>
>What stupidly simple thing am I doing wrong here?
>
>TIA,
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform