我的存储过程是这样的!
CREATE PROCEDURE proTest
@strSql as nvarchar(2000) = null, --要查询语句如 Select top 30 * from orders
@startRow as int = null, --从其开始的从零开始的记录号
@maxRows as int = null --要检索的最大记录数
AS
DECLARE @stopRow as int
set @stopRow = @startRow + @maxRows set @strSql = N' Select top ' + CAST(@StopRow as nvarchar(9)) + '*, IDENTITY(int,1,1) AS TempIDKey_Num '
+ ' INTO #New_Table '
+ ' FROM( ' + @strSql + ') A '
+ ' Select * From #New_Table Where TempIDKey_Num>=' + CAST(@StartRow as nvarchar(9))
+ ' DROP TABLE #New_Table '
execute sp_executesql @strSql
GO怎么取到他的返回记录数、当前页码
CREATE PROCEDURE proTest
@strSql as nvarchar(2000) = null, --要查询语句如 Select top 30 * from orders
@startRow as int = null, --从其开始的从零开始的记录号
@maxRows as int = null --要检索的最大记录数
AS
DECLARE @stopRow as int
set @stopRow = @startRow + @maxRows set @strSql = N' Select top ' + CAST(@StopRow as nvarchar(9)) + '*, IDENTITY(int,1,1) AS TempIDKey_Num '
+ ' INTO #New_Table '
+ ' FROM( ' + @strSql + ') A '
+ ' Select * From #New_Table Where TempIDKey_Num>=' + CAST(@StartRow as nvarchar(9))
+ ' DROP TABLE #New_Table '
execute sp_executesql @strSql
GO怎么取到他的返回记录数、当前页码
@xx int out
你的存储过程参数可以为:页码,每页记录数,检索条件,返回DataSet。
分页存储过程的分页部分,可以在程序里实现。
(
@SQL nVARCHAR(4000),
@Page int,
@RecsPerPage int,
@ID VARCHAR(255),
@Sort VARCHAR(255)
)
ASDECLARE @Str nVARCHAR(4000)SET @Str='SELECT TOP '+CAST(@RecsPerPage AS VARCHAR(20))+' * FROM ('+@SQL+') T WHERE T.'+@ID+' NOT IN
(SELECT TOP '+CAST((@RecsPerPage*(@Page-1)) AS VARCHAR(20))+' '+@ID+' FROM ('+@SQL+') T9 ORDER BY '+@Sort+') ORDER BY '+@SortPRINT @StrEXEC sp_ExecuteSql @Str
GO这个呢?又是怎么取得值?
select 返回值不就行了,比较简单