Microsoft SQL Server Limit Result Set Limiting With TOP


Example

This example limits SELECT result to 100 rows.

SELECT TOP 100 *
FROM table_name;

It is also possible to use a variable to specify the number of rows:

DECLARE @CountDesiredRows int = 100;
SELECT TOP (@CountDesiredRows) *
FROM table_name;