Luis Cazares (4/6/2016)
Ed Wagner (4/6/2016)
Iwas Bornready (4/6/2016)
This is great. I didn't know this simple trick.
This is a QOTD that's 3 1/2 years old.
And this functionality is no longer guaranteed to work as the ORDER BY will be ignored when using TOP 100 PERCENT.
Ed.. 3 1/2 year? Its from 2008, I haven't had any coffee so I can't tell you how long ago that was but I suspect it was longer than 3 1/2 years.
To Luis' point - for a presentation ORDER BY in a view (which I do sometimes just for testing) I do a TOP (1000000000000) which will not be ignored (nor does it affect the cardinality estimation when the optimizer create's a query plan).
"I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."
-- Itzik Ben-Gan 2001