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 |
|
mohd.taheri
Starting Member
5 Posts |
Posted - 2010-06-30 : 08:25:30
|
| most of the time we use the following query for paging.we would satisfy about any Idea or other Solutions :) declare @Page int, @PageSize int set @Page = 1;set @PageSize = 10; with PagedResult AS( select ROW_NUMBER() over (order by id) as RowNum, * from Table1)select * from PagedResultwhere RowNum between case when @Page > 1 then (@PageSize * @Page) - @PageSize + 1 else @Page end and @PageSize * @Pageorder by id Regards |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-06-30 : 19:19:11
|
| [CODE]with PagedResult AS(select ROW_NUMBER() over (order by id) as RowNum, * from Table1)select * from PagedResultwhere RowNum between (@PageSize * (@Page - 1)) + 1 and @PageSize * @Pageorder by id[/CODE]=======================================A couple of months in the laboratory can save a couple of hours in the library. -Frank H. Westheimer, chemistry professor (1912-2007) |
 |
|
|
|
|
|