Home >Database >Mysql Tutorial > SQLServer2005+分页SQL
declare @pagenum int = 1;declare @pagesize int = 3;WITH Tmp AS (SELECTROW_NUMBER() OVER (ORDER BY uid ASC) AS colnum,uid,unameFROM dbo.users o1)SELECT uid,uname FROM TmpWHERE colnum(@pagenum-1)*@pagesize AND colnum=@pagenum*@pagesize;
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