Is there some way to make SQL Server Management Studio return rows descending by default ? Every time i open a table via the menu (for instance by selecting return all rows), i get the oldest rows at the top. I know i can add 'order by desc' in the sql statement, but typing that is getting annoying :)
You can use the ASC and DESC keywords to specify ascending (smallest value first) or descending (largest value first) order. The default order is ascending.
The ORDER BY statement in SQL is used to sort the fetched data in either ascending or descending according to one or more columns. By default ORDER BY sorts the data in ascending order. We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
In SQL, what is the default sort order of the Order By clause? By default, the order by statement will sort in ascending order if no order (whether ascending or descending) is explicitly specified.
There is no default sort order in SQL
If you are seeing "oldest" on top then that may be the fastest way for the engine to retrieve it because that is how it is stored on disk.
You are not guaranteed to get it in this order, consider it "unordered" unless you specify an order!
ORDER BY
is the only way to have results in a specific order.
Ordering can be an expensive operation depending on the table and order specified, so unordered is the norm.
What JNK says is 100% correct.
But if you just want it to normally work, and only when you open a table rather than when you query a table...
Try adding a clustered index, with the first indexed field being indexed in descending order. This will likely actually cause what you need.
(If you already have a clustered index on that field, edit its properties and change its ordering.)
This is only a sensible idea if such an index is friendly to the actual use of the table. It would be self defeating to have an index that's useless programatically, just for your convenience ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With