手机
当前位置:查字典教程网 >编程开发 >mssql数据库 >分页的存储过程
分页的存储过程
摘要:复制代码代码如下:Createproceduresp_pageQuery@sqlstrnvarchar(4000),@page_indexi...

复制代码 代码如下:

Createproceduresp_pageQuery

@sqlstrnvarchar(4000),

@page_indexint,

@page_sizeint,

@rec_countintout--

as

setnocounton

declare@cursor_idint

declare@rowcountint

execsp_cursoropen@cursor_idoutput,@sqlstr,@scrollopt=1,@ccopt=1,@rowcount=@rowcountoutput

set@rec_count=@rowcount

set@page_index=(@page_index-1)*@page_size+1

IF@rec_count>0

BEGIN

execsp_cursorfetch@cursor_id,16,@page_index,@page_size

END

ELSE

BEGIN

Select'test'='null'Where1=2

END

execsp_cursorclose@cursor_id

setnocountoff

GO

在要用的时候在那个存储过程里调用

复制代码 代码如下:

CreatePROCEDURE[dev].[P_Mobile_Comment_Page]

@course_ware_idint,

@recCountPerPageint=1,

@pageIndexint=1,

@recordCountint=0out

AS

DECLARE@sqlnvarchar(4000)

SET@sql="

Selectseg_id,course_ware_id,subject,cust_name,content,create_date

FROMT_COURSEWARE_COMMENT

Wherecourse_ware_id="+cast(@course_ware_idasvarchar(10))+"

ORDERBYseg_id"

EXECsp_Pagequery@sql,@pageIndex,@recCountPerPage,@recordCountout

GO

【分页的存储过程】相关文章:

分页存储过程(一)使用sql2005的新函数构造分页存储过程

分页存储过程(用存储过程实现数据库的分页代码)

SQL Server 大量数据的分页存储过程代码

SQL Server两种分页的存储过程使用介绍

一个比较实用的大数据量分页存储过程

通用SQL存储过程分页以及asp.net后台调用的方法

实现SQL分页的存储过程代码

三种SQL分页查询的存储过程代码

asp.net安全、实用、简单的大容量存储过程分页第1/2页

基于Sql Server通用分页存储过程的解决方法

精品推荐
分类导航