Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
View not respecting ORDER BY clause
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01348243
Message ID:
01413710
Views:
61
>>Hi all,
>>
>>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,
>
>Evan,
>
>This is by design.
>
>See http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/ff1ee747-41d0-4664-8114-d0eaa9fea53f

This link in one of the answers explains it especially well IMO, in particular the workaround of using ORDER BY when retrieving data from the view --

http://sqlblog.com/blogs/tibor_karaszi/archive/2007/11/28/sorted-views.aspx

It is mighty curious that SS lets you generate code it discards at run time.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform