使用数据库手工分页存储过程示例

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


posted @ 2011-10-17 22:01  至道中和  阅读(109)  评论(0编辑  收藏  举报