I have a search query on my page. However, since the resultset may be very large, I want to retreive only those results that are currently shown on the gridview page.
Often a user won't browse through more than a couple of pages, so it's b-*** to send all the records to the client.
I know that with a sp you can define that you want to retrieve the first or second x records, but I want to do this with SQL...is that possible?You could put a TOP 100 or something in your search query and page them at the client side or if you want to use SQL to do the paging, you'd be doing the search over and over again for each page. You *could* get a few duplicate records. since, I am assuming you'd do a top 10 or 20 from the query to show them on the page and when you do the search again, you are starting fresh and there isnt an easy way to remember the previous search. unles you store the result set you first got into some table (you could put the spid in one column) and use the spid to get the next result set. Obviously you'd have to worry about cleaning up the table periodically in such a case.
Friday, March 9, 2012
limited resultset without SP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment