SELECT TOP
In a SELECT query or table expression, TOP is used with an ORDER BY clause to limit the result to rows that come first in the ORDER BY ordering. You can specify the quantity of rows you want in one of two ways: as an exact number of rows, from TOP(0) to TOP(9223372036854775807) (the largest BIGINT value), or as a percentage of rows, from TOP(0E0) PERCENT to TOP(100E0) PERCENT, using a FLOAT value. In Microsoft SQL Server 2000, you could only use a constant to specify the limit. SQL Server 2005 supports any self-contained expression, not just constants, with TOP.
To make it clear which rows are the "top" rows affected by a TOP query, you must indicate an ordering of the rows. Just as you can’t tell top from bottom unless you know which ...
Get Inside Microsoft® SQL Server™ 2005: T-SQL Querying now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.