create proc getData
(
@pageindex int, --第几页(从零开始)
@pagesize int --每页显示的数量
)
as
with a as (select row_number() over (order by spId) as row,* from shangpin)
select * from a where row between
@pageindex*@pagesize+1 and @pageindex*@pagesize+@pagesize
//shangpin : 表名
//spId : 表中的一列
//row_number() : 返回表中行的序列号,第一行从1开始
//over : 后面一般跟表中的某一列,表示row_number() 产生的序列号是根据表中的某一列来创建的
//with a as : 表示给as后面的语句所创建的虚拟表起一个别名a
(
@pageindex int, --第几页(从零开始)
@pagesize int --每页显示的数量
)
as
with a as (select row_number() over (order by spId) as row,* from shangpin)
select * from a where row between
@pageindex*@pagesize+1 and @pageindex*@pagesize+@pagesize
//shangpin : 表名
//spId : 表中的一列
//row_number() : 返回表中行的序列号,第一行从1开始
//over : 后面一般跟表中的某一列,表示row_number() 产生的序列号是根据表中的某一列来创建的
//with a as : 表示给as后面的语句所创建的虚拟表起一个别名a
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16436858/viewspace-612023/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16436858/viewspace-612023/