限制與 TOP

此示例將 SELECT 結果限制為 100 行。

SELECT TOP 100 *
FROM table_name;

也可以使用變數來指定行數:

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