Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table default sort order
Message
 
 
To
14/03/2008 09:25:02
General information
Forum:
Microsoft SQL Server
Category:
Database design
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01302099
Message ID:
01302103
Views:
7
W/o ORDER BY there's no guaranteed sort order for the result of a query. The sort order will depends on what execution paln the query optimizer chooses. For single table quieries with clustered index the result will be, most likely, in the clustered index order.
The bottom line, use ORDER BY to get desired order.

>I have a lookup table (for pull-down menu values). The table has a primary key - clustered index on a field desired to sort the default order of the list (without having to use 'order by'). The actual data field is also a unique index, and has a foreign key in the related table.
>
>The trouble is that the table does not get default-ordered by the primary key - clustered index. It is ordered by the data field unique index. I have experimented with test tables, and it does not seem to matter what order the indexes are created in, and I have not been able to do it in a fashion to get the default order by the sorting field.
>
>I have been under the evident delusion that the primary key, clustered index (especially if it is the first field in the table) is used by SQL as the default ordering mechanism.
>
>I have tried to find documentation on default ordering, but have been unsuccessful. Can anyone shed some light on this?
>
>All help is appreciated.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform