Zath Posted October 21, 2013 Share Posted October 21, 2013 (edited) Hello. Is it possible to change the underlying order of a table with DESC ? I run a game server where items are offered for sale. Users call up lists of items which need to be displayed as most recent at the top. Having learnt that I can add ORDER BY FLD_SELLDATE DESC to the list calling stored procedures, I can correct the bug and display items in the correct order. However, there is one list option that has no associated stored procedure and that's the full item list so I can't sort this with DESC, hence my question. If it is possible to change the whole table, would this negate the changes made to the stored procedures ? Thanks PS I'm using MS SQL Server Management Studio 2012 Edited October 22, 2013 by Zath Link to comment Share on other sites More sharing options...
niche Posted October 22, 2013 Share Posted October 22, 2013 Depending on how you change it, yes. Link to comment Share on other sites More sharing options...
Zath Posted October 22, 2013 Author Share Posted October 22, 2013 Care to elaborate ? The table is always live and its contents can be called in game by clicking a link. However, I can't pick up that call server side via SQL. Is it achieved with a query or does the table setup itself need changing regardless of data within ? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 22, 2013 Share Posted October 22, 2013 If the query does not have an ORDER BY clause, and the table does not have a clustered index, then the sort order is undefined. The records could be returned in any order. If the table has a clustered index then the records will be returned in the order of the clustered index keys. It's generally considered best practice to always use an ORDER BY clause if the sort order is significant instead of trying to rely on a default sort order that might change from query to query. http://www.dbforums.com/microsoft-sql-server/478835-default-sort-order-when-using-select-no-order-clause.html Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now