Tuesday, August 08, 2006
TOP 100 PERCENT Doesn't Work in SQL Server 2005?
Hehe - that's what I thought when I first started playing with SQL 2005 lol. The best example out of this is the last paragraph:
"The bottom line is that even if we do the sort as part of the TOP operation in a sub-select, it does NOT guarantee anything about the output order of the query.
SELECT TOP 99 PERCENT * FROM T ORDER BY col1
is not the same as:
SELECT * FROM (SELECT TOP 99 PERCENT * FROM T ORDER BY col1) AS A
The top query guarantees the output order of the query. The bottom query does not (even if the rows happen to come back in sorted order)"
Great post - thanks QueryOptTeam!
"The bottom line is that even if we do the sort as part of the TOP operation in a sub-select, it does NOT guarantee anything about the output order of the query.
SELECT TOP 99 PERCENT * FROM T ORDER BY col1
is not the same as:
SELECT * FROM (SELECT TOP 99 PERCENT * FROM T ORDER BY col1) AS A
The top query guarantees the output order of the query. The bottom query does not (even if the rows happen to come back in sorted order)"
Great post - thanks QueryOptTeam!