I am new to SQL Server 2008, and I need some help in query for pagination logic on my JSF page.
Here is my query:
select *
from ShipmentHistory sh
where sh.CCIPortID in ?
order by sh.TrackingNumber, sh.CreateTimeStamp
for the first time I need to get only 100 records from db and when ever the user clicks on next on my JSF page I need to fetch next 100 records only. Am keep tracking of user clicks on the page i.e next and previous button.
Thanks for your time.
First, you’ll need to perform a count of your result set, so you know how many total records you have, and how many pages will be displaying the data.
Next, you’ll need to specify the start and end rows that you want to retrieve, and then use a query similar to the following to pull that chunk of your results.
Note: Don’t use
SELECT *, replace this with the actual columns that you need to return.