我用asp利用oledb连接到sql server 2000,
执行select 1 select 2
查询分析器抓到的是:declare @P1 int
set @P1=0
declare @P2 int
set @P2=98305
declare @P3 int
set @P3=311300
declare @P4 int
set @P4=0
exec sp_cursoropen @P1 output, N'select * from select 1 select 2', @P2 output, @P3 output, @P4 output select @P1, @P2, @P3, @P4看抓到的那个select select * from select 1 select 2这明显是错误的嘛, 为什么会抓到它呢?
执行select 1 select 2
查询分析器抓到的是:declare @P1 int
set @P1=0
declare @P2 int
set @P2=98305
declare @P3 int
set @P3=311300
declare @P4 int
set @P4=0
exec sp_cursoropen @P1 output, N'select * from select 1 select 2', @P2 output, @P3 output, @P4 output select @P1, @P2, @P3, @P4看抓到的那个select select * from select 1 select 2这明显是错误的嘛, 为什么会抓到它呢?
@sql ntext, --要执行的sql语句
@PageCurrent int=1, --要显示的页码
@PageSize int=10, --每页的大小
@PageCount int OUTPUT --总页数
AS
SET NOCOUNT ON
DECLARE @p1 int
--初始化分页游标
EXEC sp_cursoropen
@cursor=@p1 OUTPUT,
@stmt=@sql,
@scrollopt=1,
@ccopt=1,
@rowcount=@PageCount OUTPUT--计算总页数
IF ISNULL(@PageSize,0)<1
SET @PageSize=10
SET @PageCount=(@PageCount+@PageSize-1)/@PageSize
IF ISNULL(@PageCurrent,0)<1 OR ISNULL(@PageCurrent,0)>@PageCount
SET @PageCurrent=1
ELSE
SET @PageCurrent=(@PageCurrent-1)*@PageSize+1--显示指定页的数据
EXEC sp_cursorfetch @p1,16,@PageCurrent,@PageSize--关闭分页游标
EXEC sp_cursorclose @p1
這是系統用於分頁游標存儲過程