I noticed one different behavior in SQL Server 2005 comparing with 2000:
If you run “select * from (select top 100 percent * from [table name] order by lastname) as temp” on SqlServer 2000 and on SqlServer 2005, you will see the difference. In 2000, the list you get is still sorted while in 2005 it's not.
The bottomline is: don’t say “order by” in a view or in a nested select statement. Putting "order by" in a view is never a good practice, in my opinion, because:
1. You have to say "top 100 percent" in order to do that
2. We should put "order by" in the most outer select so it costs minimum workload for the Sql Server (it only needs to sort the things you need at the end).
Showing posts with label ORDER BY. Show all posts
Showing posts with label ORDER BY. Show all posts
Wednesday, September 24, 2008
Subscribe to:
Posts (Atom)