Friday, March 9, 2012

Pagination with SP

I'd like to write an SP with parameters that returns specified groups rows
in ordered groups of arbitrary size. Kind of a "sliding" TOP. Like, show me
the first 40 items in a list, show me the 4th group of 40 items in a list,
show me the Nth group of X items, etc. I see this kind of thing all the time
and would prefer not to have to deal with the pagination in VB or ASP, or
get all the rows and then filter out what I don't want to display.
So, I'd like to pass in to the SP parameters for the size of each grouping
and an ordinal for the group I wanted.
CREATE PROCEDURE pagination_sp
@.ordinal int,
@.groupsize int
AS
SELECT LastName, FirstName
FROM People
ORDER BY LastName, FirstName
Thanks for any tips on how to approach this.Don
http://www.aspfaq.com/show.asp?id=2120
"Don Miller" <nospam@.nospam.com> wrote in message
news:%23oKvuTlSFHA.2784@.TK2MSFTNGP12.phx.gbl...
> I'd like to write an SP with parameters that returns specified groups rows
> in ordered groups of arbitrary size. Kind of a "sliding" TOP. Like, show
me
> the first 40 items in a list, show me the 4th group of 40 items in a list,
> show me the Nth group of X items, etc. I see this kind of thing all the
time
> and would prefer not to have to deal with the pagination in VB or ASP, or
> get all the rows and then filter out what I don't want to display.
> So, I'd like to pass in to the SP parameters for the size of each grouping
> and an ordinal for the group I wanted.
> CREATE PROCEDURE pagination_sp
> @.ordinal int,
> @.groupsize int
> AS
> SELECT LastName, FirstName
> FROM People
> ORDER BY LastName, FirstName
> Thanks for any tips on how to approach this.
>

No comments:

Post a Comment