您的位置:首页 > 其它

存储过程分页的经典例子

2009-03-14 14:13 309 查看
原文:http://www.sufeinet.com/thread-2111-1-1.html

USE [PLAYBAR_PERSONAL]
GO
/****** 对象: StoredProcedure [dbo].[CP_select_All_Customer]    脚本日期: 03/10/2009 21:09:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:   sufei
-- Create date: <2009-2-16,,>
-- Description: <查询所有的用户信息
---Table (手机号,用户名,用户信箱,用户年龄,性别,用户职业,兴趣爱好,现居地,用户积分,注册时间 ,备注)
-- =============================================
ALTER PROCEDURE [dbo].[CP_select_All_Customer]
@startindex int ,
@pagesize int
AS
BEGIN
with NewCustomer as (
select row_number()over (order by Cus_Id)as rownumber, Cus_MSISDN,Cus_Name,Cus_Email,Cus_Age,Cus_Sex,Cus_Job,Cus_Intrestings,Cus_Address,Cus_Value,Cus_RegTime,Cus_Remark,Cus_State
from Customer
where Isdelete=0
)
select rownumber, Cus_MSISDN,Cus_Name,Cus_Email,Cus_Age,Cus_Sex,Cus_Job,Cus_Intrestings,Cus_Address,Cus_Value,Cus_RegTime,Cus_Remark,Cus_State
from NewCustomer
where rownumber >=(@startindex-1)*@pagesize+1 and rownumber<=(@startindex-1)*@pagesize+(@pagesize)

select count(*) from Customer where Isdelete=0
END
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: