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 |
|
amirs
Constraint Violating Yak Guru
260 Posts |
Posted - 2009-04-07 : 09:06:12
|
| hi im my table their are 10,00000 record.it is posible to select first 10 , in next to start 11 to 20 ,in prev select 10 records and last 10 records in table to select query means is posible to pagination of first,next,prev and last record and display the 10 records.i am using sql server2005 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-07 : 09:07:44
|
Yes it is. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-07 : 09:08:33
|
quote: Originally posted by amirs hi im my table their are 10,00000 record.it is posible to select first 10 , in next to start 11 to 20 ,in prev select 10 records and last 10 records in table to select query means is posible to pagination of first,next,prev and last record and display the 10 records.i am using sql server2005
Search for Pagination+SQL Server in googleMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-07 : 09:52:49
|
quote: Originally posted by amirs hi im my table their are 10,00000 record.it is posible to select first 10 , in next to start 11 to 20 ,in prev select 10 records and last 10 records in table to select query means is posible to pagination of first,next,prev and last record and display the 10 records.i am using sql server2005
its possible using row_number() function. just use a procedure like belowCREATE PROCEDURE GetPagedResults@PageSize int=10,@PageNo int=1ASSELECT columnsFROM(SELECT ROW_NUMBER() OVER(ORDER BY PK) AS Row_No,*FROm YourTable)tWHERE t.RowNo BETWEEN (@PageNo-1)*@PageSize+1 AND @PageNo*@PageSizeGOthen call it like GetPagedResults 10,1 --gets first page recordsGetPagedResults 10,5 --gets 5th page recordsfor getting last page just useDECLARE @LastPage intSELECT @LastPage= CIELING(COUNT(1)/@PageSize) FROM YourTable |
 |
|
|
|
|
|
|
|