前几天听说可以用存储过程分页,速度很快,那位能给个例子啊,谢谢。

或者用什么更快的分页方法?不要说是数据集的,那个我觉得并不是太快。
---------------------------------------------------------------

实际上需要你的记录集有一个数字ID作为关键字,然后存储过程中查询得到分页记录,返回需要的记录,这样当然快些
---------------------------------------------------------------

学习。
---------------------------------------------------------------

UPUP
---------------------------------------------------------------

就是呀。期待高手!好吗?
---------------------------------------------------------------

先看看我的帖子。
正在讨论http://expert.csdn.net/Expert/TopicView1.asp?id=1994682
---------------------------------------------------------------

共同学习:

You could use a stored procedure like this:

CREATE PROCEDURE sp_PagedItems
(
@Page int,
@RecsPerPage int
)
AS

-- We don't want to return the # of rows inserted
-- into our temporary table, so turn NOCOUNT ON
SET NOCOUNT ON

--Create a temporary table
CREATE TABLE #TempItems
(
ID int IDENTITY,
Name varchar(50),
Price currency
)

-- Insert the rows from tblItems into the temp. table
INSERT INTO #TempItems (Name, Price)
SELECT Name,Price FROM tblItem ORDER BY Price

-- Find out the first and last record we want
DECLARE @FirstRec int, @LastRec int
SELECT @FirstRec = (@Page - 1) * @RecsPerPage
SELECT @LastRec = (@Page * @RecsPerPage + 1)

-- Now, return the set of paged records, plus, an indiciation of we
-- have more records or not!
SELECT ,
MoreRecords =
(
SELECT COUNT(
)
FROM #TempItems TI
WHERE TI.ID >= @LastRec
)
FROM #TempItems
WHERE ID > @FirstRec AND ID < @LastRec

-- Turn NOCOUNT back OFF
SET NOCOUNT OFF

---------------------------------------------------------------

up
---------------------------------------------------------------

学习。
http://expert.csdn.net/Expert/topic/2017/2017449.xml?temp=.8510706

Published At
Categories with Web编程
comments powered by Disqus