sql存储过程的分页查询解决办法
sql存储过程的分页查询
我想做一个存储过程的分页查询,我自己写啦一个 有点问题?求助这中格式的分页查询
记得是存储过程的分页查询..............谢谢啦!
create proc sql_ProductDetails
@ProductTypeId int,--产品类型id
@pagesize int, --一页又多少纪录
@count int --代表当前第几页
希望大家能帮我写下完整的 呵呵 谢谢啦
------解决方案--------------------
------解决方案--------------------
正解
------解决方案--------------------
你这个好像不是我那种格式的吧:
--产品详情
create table ProductDetails
(
ProductDetailsId int primary key identity(1,1), --产品详情ID
ProductTypeId int references ProductType(ProductTypeId), ---产品类型ID
ProductDetailsName nvarchar(10) not null, --产品名称
ProductNumbers char(30) not null, --产品编号
ProductPath nvarchar(50) not null, --产品存放路径
ProductPrice float not null, --产品价格
ProductDetailss nvarchar(200) not null --产品详情
)
这个是我的产品存放表;我想直接传一个产品类型ID跟需要获取多少条数据跟需要第几页的数据
这中格式的分页查询
你那种是需要提供开始页,我程序已经写好啦!我不想修改,能不能做出我要的这中效果呢?
谢谢啦 你我sql菜鸟一个 希望你能写好注释 谢谢
------解决方案--------------------
--双top分页
SELECT top @pagesize * from
tb_time bb
where bb.id not in (select top (@pagesize*@count) id
FROM tb_time)
------解决方案--------------------
SELECT top @pagesize * from
tb_time bb
where bb.id not in (select top (@pagesize*(@count-1)) id
FROM tb_time)
------解决方案--------------------
该回复于2012-09-28 15:05:19被版主删除
我想做一个存储过程的分页查询,我自己写啦一个 有点问题?求助这中格式的分页查询
记得是存储过程的分页查询..............谢谢啦!
create proc sql_ProductDetails
@ProductTypeId int,--产品类型id
@pagesize int, --一页又多少纪录
@count int --代表当前第几页
希望大家能帮我写下完整的 呵呵 谢谢啦
------解决方案--------------------
DECLARE @START_ROW int, @MAX_ROWS int, @TOT_ROW_CNT int
SELECT @START_ROW = 1, @MAX_ROWS = 25;
WITH PAGED AS (
SELECT ROW_NUMBER() OVER(ORDER BY MyDate, MYID) AS rowNum, *
FROM TRANS_TABLE(NOLOCK)
)
SELECT *
FROM PAGED
WHERE ROWNUM BETWEEN@START_ROW AND @START_ROW + @MAX_ROWS - 1
------解决方案--------------------
正解
------解决方案--------------------
你这个好像不是我那种格式的吧:
--产品详情
create table ProductDetails
(
ProductDetailsId int primary key identity(1,1), --产品详情ID
ProductTypeId int references ProductType(ProductTypeId), ---产品类型ID
ProductDetailsName nvarchar(10) not null, --产品名称
ProductNumbers char(30) not null, --产品编号
ProductPath nvarchar(50) not null, --产品存放路径
ProductPrice float not null, --产品价格
ProductDetailss nvarchar(200) not null --产品详情
)
这个是我的产品存放表;我想直接传一个产品类型ID跟需要获取多少条数据跟需要第几页的数据
这中格式的分页查询
你那种是需要提供开始页,我程序已经写好啦!我不想修改,能不能做出我要的这中效果呢?
谢谢啦 你我sql菜鸟一个 希望你能写好注释 谢谢
------解决方案--------------------
--双top分页
SELECT top @pagesize * from
tb_time bb
where bb.id not in (select top (@pagesize*@count) id
FROM tb_time)
------解决方案--------------------
SELECT top @pagesize * from
tb_time bb
where bb.id not in (select top (@pagesize*(@count-1)) id
FROM tb_time)
------解决方案--------------------
该回复于2012-09-28 15:05:19被版主删除