Hello!
The ORDER BY leads to a wrong execution plan.
There is a connect item describing a similar problem with varchar.
http://connect.microsoft.com/SQLServer/feedback/details/657590/optimizer-error-when-tertiary-weights-is-used-internaly
The "order by" provides a guarantee on the order of rows returned to the client. However it does not provide a guarantee on the order of evaluation of computed values.
In your case the ORDER BY is not necessary for the select and in SSMS 2012 it is marked with a red line, because it seems not to be right in this case.
What do you think ORDER BY should do for you?
Have a nice day,
Christoph
--
Microsoft SQL Server MVP - <a href="http://www.insidesql.org/blogs/cmu">Blog</a>
No comments:
Post a Comment