SQLServer2005+分页SQL

declare @pagenum int = 1;

declare @pagesize int = 3;

WITH Tmp AS 

(

	SELECT	ROW_NUMBER() OVER (ORDER BY uid ASC) AS colnum,

		uid,

		uname

	FROM dbo.users o1

)

SELECT uid,uname FROM Tmp

WHERE colnum>(@pagenum-1)*@pagesize 

AND colnum<=@pagenum*@pagesize;

 

你可能感兴趣的:(sqlserver2005)