Wednesday 7 September 2011

How to set paging from sql server


Note : Some Time our gird view or data grid become very Time loaded due to No. of records(like more than 50000). For sort out this problem we use Paging from Database table



declare @startRowIndex int
declare @pageSize int

set @startRowIndex =1
set @pageSize = 10

select * from (SELECT ROW_NUMBER() OVER (ORDER BY contact_id ASC) as RowNum, * FROM address)
as ArticleList
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @pageSize) - 1
ORDER BY RowNum ASC

No comments:

Post a Comment