SQL Server 2005引入的新方法。
SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY keyField DESC) AS rowNum, *
FROM tableName) AS t WHERE rowNum > start AND rowNum <= end
其中:
keyField为表tableName的一个字段(最好是主键);
tableName为查询的表名;
DESC可以按需换为ASC;
start为要取的结果集的起始记录 end为要取的结果集的结尾记录,可由:(start + pageSize)计算得出。
时间: 2024-10-07 07:17:02