正品水晶
![](https://img-my.csdn.net/uploads/201303/19/1363683988_9778.jpg)
--参数
declare @pageSize int,@page int;
--定义拼接sql 的参数
declare @EngSql2 varchar(4000)
--用子查询生成自动编号字段RowID,再根据参数@pageSize、@page计算页数、显示数据
set @EngSql2='select * from (selectRowID=row_number() over(order by id) as row_number,* from tableName) as a'
set @EngSql2=@EngSql2+' where a.RowID>'+CAST(@pageSize*(@page-1) AS VARCHAR(20))+'
and a.RowID<='+CAST(@pageSize*@page AS VARCHAR(20))+' '
EXEC(@EngSql2)
正品水晶![](https://img-my.csdn.net/uploads/201303/19/1363683988_9778.jpg)