加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

SQL SERVER 2005 分页存储过程

发布时间:2020-12-12 12:34:45 所属栏目:MsSql教程 来源:网络整理
导读:项目介绍: 评论分页存储过程 项目背景:asp.net(c#) +sql2005 存储过程代码: 以下为引用的内容: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: zhaoyang -- Create date: 2009-8-21 -- De
以下为引用的内容:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: zhaoyang
-- Create date: 2009-8-21
-- Description: 显示用户评论列表
-- =============================================
CREATE PROCEDURE [dbo].[CommentShowList_zy]
@GeneralID int,--信息ID
@ParentID int,--父ID
@OrderFlag int,--排序标示 0标示最新 1标示热门
@CurrentPage int,--当前页码
@pagesize int --每页的数据条数
AS
BEGIN
IF(@ParentID=0) --读取评论内容
BEGIN
IF(@OrderFlag=0)
BEGIN
with a as(
select *,px=row_number() over(order by id desc) from cms_wangpiao.dbo.Comment_zy where GeneralID=@GeneralID and ParentID=@ParentID
)
select * from a where px BETWEEN(@CurrentPage-1)* @pagesize+1 and @CurrentPage* @pagesize
END
IF(@OrderFlag=1)
BEGIN
with b as(
select *,px=row_number() over(order by a.CountReply desc ) from (
select *,(select count(0) from Comment_zy czb where czb.ParentID=cza.id) as CountReply from Comment_zy cza where GeneralID=@GeneralID and ParentID=@ParentID ) a
)
select * from b where px BETWEEN (@CurrentPage-1)* @pagesize+1 and @CurrentPage* @pagesize
END
END
ELSE--读取评论回复内容
BEGIN
select * from cms_wangpiao.dbo.Comment_zy where ParentID=@ParentID ORDER BY id desc
END
END

  来自:http://www.cnblogs.com/studyplay/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

  项目介绍: 评论分页存储过程

  项目背景:asp.net(c#) +sql2005

  存储过程代码:

    推荐文章
      热点阅读