在SQL Server中,有几种不同的方法可以进行分页操作:
SELECT *
FROM table
ORDER BY column
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;
SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER (ORDER BY column) AS RowNum
FROM table
) AS SubQuery
WHERE RowNum BETWEEN 11 AND 20;
WITH CTE AS (
SELECT *,
ROW_NUMBER() OVER (ORDER BY column) AS RowNum
FROM table
)
SELECT *
FROM CTE
WHERE RowNum BETWEEN 11 AND 20;
这些是在SQL Server中进行分页操作的几种常见方法。具体选择哪种方法取决于你的需求和查询的复杂性。