发布网友
共1个回答
热心网友
create proc 电影存储过程 --翻页存储过程
@PageSize int, --每页面显示数据条数
@PageIndex int, --页面索引
@PageCount int output, --总页数
@名称 nvarchar(100)
as
--查询范围 (@PageSize*@PageIndex+1) 起始行
-- @PageSize*(@PageIndex+1) 结束行
select * from(select Row_Number() over (order by 影片ID) as id, * from(
select * from 电影 where 名称 like '%'+@名称+'%' or 主演 like '%'+@名称+'%' )a )b where id between (@PageSize*@PageIndex+1) and @PageSize*(@PageIndex+1)
--得到数据行数
select @PageCount=count(1) from 电影 where 名称 like '%'+@名称+'%' or 主演 like '%'+@名称+'%'
--计算出总行数
set @PageCount= (@PageCount-1)/@PageSize+1
print @PageCount
这个是我写过的分页存储过程 给你参考下啊!