使用数据库手工分页存储过程示例
ALTER PROCEDURE dbo.Pro_ProductsPage
(
@PageSize int,
@Currentindex int
)
AS
declare @a nvarchar(50)
declare @b nvarchar(50)
declare @c nvarchar(500)
set @a=convert(nvarchar,@PageSize)
set @b=convert(nvarchar,@PageSize*(@Currentindex-1))
set @c='select top '+@a+' * from FU_ProductsInfo where ProductsID not in (select top '+@b+' ProductsID from FU_ProductsInfo)'
set @c='select * from ('+@c+')k order by ProductsID desc'
execute sp_executesql @c
RETURN
(
@PageSize int,
@Currentindex int
)
AS
declare @a nvarchar(50)
declare @b nvarchar(50)
declare @c nvarchar(500)
set @a=convert(nvarchar,@PageSize)
set @b=convert(nvarchar,@PageSize*(@Currentindex-1))
set @c='select top '+@a+' * from FU_ProductsInfo where ProductsID not in (select top '+@b+' ProductsID from FU_ProductsInfo)'
set @c='select * from ('+@c+')k order by ProductsID desc'
execute sp_executesql @c
RETURN
本文来自博客园,作者:至道中和,转载请注明原文链接:https://www.cnblogs.com/voidobject/archive/2011/10/17/3975516.html