现在的位置: 首页 > 综合 > 正文

sql 分页技术

2014年03月16日 ⁄ 综合 ⁄ 共 920字 ⁄ 字号 评论关闭

--create table TB_Page
--(
--    PId            int primary key identity(1,1),
--    PName        varchar(100)
--)

--drop table tb_Page

--declare
--@count        int,
--@num        int,
--@sql        varchar(max),
--@Pname        varchar(100)
--select @count=1000;
--select @num=1;

--while(@num<@count)
--begin
--    select @Pname='第'+convert(varchar(100),@num)+'页';
--    select @sql='insert into TB_Page (PName)values('''+@Pname+''')';
--    select @num=@num+1;
--    exec(@sql)
--end

--select * from TB_Page

--select * from
--    (select top 100 * from
--        (select top 299 * from TB_Page order by PId asc) tb1) tb2
--order by PId asc

--create procedure proc_Page
--    @page        int,
--    @pcount        int
--as
--begin
--    SELECT ROW_NUMBER() over(order by PId asc) as Num, PId,PName
--    FROM
--        (
--            SELECT ROW_NUMBER() OVER (ORDER BY PId asc) AS RowNum, *
--            FROM TB_Page
--        ) AS T
--    WHERE T.RowNum> (@page-1)*@pcount  and T.RowNum<= @page*@pcount
--end
--go

--drop proc proc_Page

--exec proc_Page 3,100

【上篇】
【下篇】

抱歉!评论已关闭.