C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Pagination in SQL Server 2005


Posted Date: 25 Sep 2008    Resource Type: Code Snippets    Category: SQL

Posted By: @@@ Hyderabadi Biryani @@@       Member Level: Diamond
Rating:     Points: 10



There are couple of ways to implement the pagination.

Lets take an example of DataGrid in ASP.NET where you need set "AllowPaging" to True to enable the DataGrid's paging features. Along with the this this property, there is another PageSize property that specifies how many records to display per page and the default value of this is 10.

In this case it will get all the records which satifies the search criteria. This is has somany performance issues. Instead of this get the No.Of records based on the Page you are looking in and get the data. This way it will improve the performance of the page in great way.

The below piece of code uses the new Analytical functions available in SQL Server 2005 to implement the pagination.


SELECT * FROM
(
SELECT ROW_NUMBER() OVER(ORDER BY ROWNUM) AS ROW_NUM,*
FROM
(
SELECT E.EMPID,E.NAME,E.DOJ,E.SAL,D.DEPTNO,D.DNAME
ROW_NUMBER() OVER
(ORDER BY E.SAL) AS ROWNUM
FROM EMP E, DEPT D
WHERE E.DEPTNO = D.DEPTNO
) AS V
WHERE v.ROWNUM < @PageRowEndNumber
) AS V1
WHERE V1.ROW_NUM >= @PageRowStartNumber
[/ODE]







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Vijaya Kadiyala  .  SQL Server 2005 Features  .  ROWNUM  .  ROW_NUMBER  .  RONUM in SQL Server  .  Pagination in SQL Server  .  Analytical Functions in SQL Server  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Implementation of Cursor in SQL Server
Previous Resource: Sequence in SQL Server
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween mask

Contact Us    Privacy Policy    Terms Of Use