mark 4643 (10/10/2012)
Hi AllI'm trying to optimize a monstrous query in a report that a vendor supplied. Part of the query has SELECT TOP(100 PERCENT) which makes no sense to me.
I see no point in the TOP (100 PERCENT) surely it'll just return all records, or am I missign something?
Regards
Mark
You cannot put order by clause alone inside a subquery; in order to do that you need to specify top 100 percent or you can use FOR XML clause. This fundamental holds true for views, inline functions, derived tables, subqueries, and common table expressions where the order by clause is invalid without TOP or FOR XML operators.
Hope this helps:-)
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter