In een ander topic kwam het verschil tussen SET ROWCOUNT n en SELECT TOP n ter sprake. Ik ging er altijd vanuit de ROWCOUNT op basis van de ongesorteerde resultset was en TOP op basis van de gesorteerde resultset, ik keek echter even in Books Online en las daar het volgende:
(behalve het feit dat SET ROWCOUNT werkt tot het 'uit' gezet wordt natuurlijk)
Hierin staat toch duidelijk dat beide uiteindelijke resultsets wel rekening houden met de ORDER BY clausule. Een testje op de pubs database gaf voor beide statements ook dezelfde resultaten. Kan ik nu niet lezen, of staat hier gewoon dat ze beide hetzelfde doenIf a SELECT statement that includes TOP also has an ORDER BY clause, the rows to be returned are selected from the ordered result set. The entire result set is built in the specified order and the top n rows in the ordered result set are returned.
The other method of limiting the size of a result set is to execute a SET ROWCOUNT n statement before executing a statement. SET ROWCOUNT differs from TOP in these ways:
The SET ROWCOUNT limit applies to building the rows in the result set after an ORDER BY is evaluated. When ORDER BY is specified, the SELECT statement is terminated when n rows have been selected from a set of values that has been sorted according to specified ORDER BY classification.
Oops! Google Chrome could not find www.rijks%20museum.nl