谈谈Java调用SQL Server分页存储过程

谈谈Java调用SQL Server分页存储过程
复制USE [Db_8za8za_2]      GO      SET ANSI_NULLS ON GO      SET QUOTED_IDENTIFIER ON GO      -- =============================================    -- Description:    <Description,谈谈,通用分页存储过程>    -- =============================================    ALTERPROCEDURE [dbo].[paging ]      -- Add the parameters for the stored procedure here    --传入参数        @SqlStr nvarchar(4000), --查询字符串        @CurrentPage int, --第N页(当前页数)        @PageSize int--每页行数    AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from    -- interfering with SELECT statements.    SET NOCOUNT ON;      --定义变量    DECLARE @CursorId int--CursorId是游标的b2b供应网id    DECLARE @Rowcount int--总记录(行)数    DECLARE @pageCount int--总页数    -- Insert statements for procedure here    EXEC sp_cursoropen @CursorId output,@SqlStr,              @Scrollopt=1,@Ccopt=1,@Rowcount=@Rowcount OUTPUT SET @pageCount=CEILING(1.0*@Rowcount/@PageSize)--设置总页数    SELECT @pageCount      AS 总页数,@Rowcount AS 总行数,@CurrentPage AS 当前页 --提示页数        IF(@CurrentPage>@pageCount)--如果传入的香港云服务器当前页码大入总页码数则把当前页数设为***一页    BEGIN SET @CurrentPage = @pageCount--设置当前页码数    END     IF(@CurrentPage<=0)--如果传入的源码下载当前页码大入总页码数则把当前页数设为***页    BEGIN SET @CurrentPage = 1--设置当前页码数    END SET @CurrentPage=(@CurrentPage-1)*@PageSize+1 --设置当前页码数    EXEC sp_cursorfetch @CursorId,16,@CurrentPage,@PageSize      EXEC sp_cursorclose @CursorId    --关闭游标    SET NOCOUNT OFF END 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.
数据库
上一篇:电脑桌面开关布局教程(让你的桌面整洁有序,工作高效利索)
下一篇:华为畅享7Plus32如何为你带来无限乐趣?(探索畅享7Plus32的全方位功能和卓越性能)