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.
| Author |
Topic |
|
desaiva
Starting Member
2 Posts |
Posted - 2009-12-31 : 08:29:27
|
| Hi there,I want to create store procedure where I can pass starting positon and end position for records as parameters and based on that I can retrieve record set.For ex. if I pass starting position as 6th and end position as 10th then I should be able to retrieve records from 6th to 10th position for select statement which I written.I want to achieve this functionality for custom paging in grid on web page.I have already watched cetain articles on internet for writing store procedure for custom paging of the grid but they don't match to my criteria. Is there any way I can achieve set of records based on starting position and end position?I am exlploring on this issue lot but till no success. Your help would be precious for me.Thanks in advance. |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2009-12-31 : 08:38:29
|
| I am not sure how your data is set up, but if you want the top 6 - 10 records you can use Row_Num() (or rank or dense rank depending on ties and what not) to get those passed back to you.Something likeSelect *, a.row from (select *, Row_num() OVER (--Your specifics--) as Row FROM #Your_Table) a Where a.row between 6 and 10 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2009-12-31 : 10:22:06
|
| Thanks fred :) ; yes the above link is certainly more descriptive and better for paging examples, and is off of the same idea. |
 |
|
|
|
|
|