摘要: SQL查找第n条记录的方法:select top 1 * from table where id not in (select top n-1 id from table) temptable0 SQL查找第n条开始的m条记录的方法:select top m * from table where id not in (select top n-1 id from table) temptable0... 阅读全文
posted @ 2006-01-22 18:01 致远钓客 阅读(333) 评论(0) 推荐(0)
摘要: 如果用一般的SELECT * 查询SQL数据库,然后用recordset进行分页的话,在返回结果很多的情况下将会是一个漫长的过程,而且很消耗内存.你可能会有感觉,用access也比SQL快.其实我们可以只取出我们每页需要显示的记录数,这样的速度是惊人的,非常快.这里我们会用到聚集索引来快速确定我们需要取出的记录数的位置.如下面:if p>1 then 'p为PAGE页数if n="next" th... 阅读全文
posted @ 2006-01-22 17:59 致远钓客 阅读(206) 评论(0) 推荐(0)
摘要: 这个分页在200万数据下也只需12秒左右,在我的机上测试,AMD 1800XP 512M 120G西数 CREATE procedure seldata (@pagesize int, @pageindex int) as set nocount on declare @RecordCount int select @RecordCount=count(id) from test if(@page... 阅读全文
posted @ 2006-01-22 17:28 致远钓客 阅读(162) 评论(0) 推荐(0)
摘要: 1SQL Server 存储过程的分页,这个问题已经讨论过几年了,很多朋友在问我,所以在此发表一下我的观点 2建立表: 3 4CREATE TABLE [TestTable] ( 5 [ID] [int] IDENTITY (1, 1) NOT NULL , 6 [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,... 阅读全文
posted @ 2006-01-22 16:53 致远钓客 阅读(365) 评论(1) 推荐(0)