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
 SQL Server Development (2000)
 Finding the previous and next rows for a particular row

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-24 : 09:21:47
Mikey writes "Currently I'm opening a recordset using dynamic SQL and determining what the next and previous rows are by opening the whole recordset and moving previous and next to find the corresponding id's so I know when users wish to move previous or next, those id's are the id's to look for.

What I would like to do is open smaller subsets of the recordset so I'm only dealing with the rows I need.

Ie. the row where ID = X, the row previous to it and the row after it.

The SQL string I use is also may or may not included a dynamic where clause where the users of my database can search for rows where particular fields have particular values.

Finding the first and last rows I know are particular easy because you can use the TOP predicate to find them. Is there a better way than dynamic SQL to find the others?"
   

- Advertisement -