首页  >  文章  >  数据库  >  MSSQL根据ID进行分页实现方法

MSSQL根据ID进行分页实现方法

WBOY
WBOY原创
2016-06-07 16:17:521227浏览

代码如下: ALTER PROCEDURE [a0919194122].[dnt_getappinvitelist] @uid int, @pageindex int, @pagesize int AS DECLARE @startRow int, @endRow int SET @startRow = (@pageIndex - 1) * @pagesize IF @pageindex = 1 BEGIN EXEC( 'SELECT TOP '+@pagesize

代码如下:

ALTER PROCEDURE [a0919194122].[dnt_getappinvitelist]
@uid int,
@pageindex int,
@pagesize int
AS
DECLARE @startRow int,
@endRow int
SET @startRow = (@pageIndex - 1) * @pagesize
IF @pageindex = 1
BEGIN
EXEC(
'SELECT TOP '+@pagesize+' [id],[typename],[appid],[type],[fromuid],[touid],[myml],[datetime],[hash] FROM [dnt_myinvite] WHERE [touid]='+@uid+' ORDER BY [id] DESC'
)
END
ELSE
BEGIN
EXEC('
SELECT
TOP '+@pagesize+'
[id],[typename],[appid],[type],[fromuid],[touid],[myml],[datetime],[hash]
FROM [dnt_myinvite]
WHERE [touid]='+@uid+'
AND [id] FROM [dnt_myinvite]
WHERE [touid]='+@uid+'
ORDER BY [id] DESC
) AS T
)
ORDER BY [id] DESC
')
END

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn