--又快又簡單的sql2005分頁存儲過程 DECLARE @rows_per_page AS INTEGER DECLARE @current_page AS INTEGER DECLARE @start_row_num AS INTEGER -- 設置每頁的行數 SET @rows_per_page = 20 -- 設置要顯示的頁號(從1開始) SET @current_page = 2 -- 設置開始行號 SET @start_row_num = (@current_page - 1) * @rows_per_page WITH t AS ( SELECT ROW_NUMBER() OVER(ORDER BY id) AS row_number, * FROM testtable ) SELECT * from t WHERE row_number BETWEEN @start_row_num AND @start_row_num + @rows_per_page