Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Efficient Paging

Author  Topic 

geoffb
Starting Member

1 Post

Posted - 2003-04-22 : 16:37:34
Hi,
I have a query which is used in a search type function. The search function is shown on a website, 10 records at a time. You can page backward and forward by the next or previous 10. I'm sure you've all seen this.

The question - to implement paging, I have to query the entire database, then limit the output in the client app by specifying the start and end rows.

I'm wondering if there is a more efficient way to do this - say by limiting the recordset in the stored procedure itself.

It seems a bit wasteful to return hundreds of rows to the client, and only use 10 at a time... there must be a better way.

Geoff B

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2003-04-22 : 17:25:39
Reply check the article entitled "Whats After Top". It will show you how to traverse sets of records within a larger set using nested top queries.

Justin

"Oh boy sleep! That's where I'm a pirate" - Ralph Wiggum
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-04-23 : 10:29:58
Also, check out this thread:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25496

I post some code that lets you return rows @a through @b from a table or query.

By nature, doing that type of thing in SQL usually isn't super efficient because you need to explicity come up with a way to calc row numbers yourself because SQL is not designed to assign row numbers to result sets.


- Jeff
Go to Top of Page
   

- Advertisement -