Pagination with SQL Server 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jdom
    New Member
    • Sep 2008
    • 10

    #1

    Pagination with SQL Server 2005

    I am new to stored procedure. I would like to call this to my asp page but just don't have clue how to.
    Reason i have to this because i have a largedata base.

    Here is the query from my database:
    Code:
    SELECT AD_ID,make, model, year, imagea, ad_dated FROM ADS WHERE Make = "BMW" ORDER BY AD_ID DESC
    Make is querystring

    I did try but with no success. if anyone can help or guide me to a sample tutorial

    i will appreciate it/

    Thank you

    Code:
    DECLARE @rowsPerPage int,
        @pageNum int,
     @startRow int,
     @endRow int
    
    SET @rowsPerPage = 10
    SET @pageNum = 3
    
    SET @startRow = ((@pageNum- 1) * @rowsPerPage)+1
    SET @endRow = @startRow + @rowsPerPage -1
    
    SELECT * FROM (
     SELECT row_number() OVER (ORDER BY id) as resultNum, id
     FROM regTrackingHistory
    ) as numberResults
    WHERE resultNum  BETWEEN @startRow AND @endRow
    Last edited by DrBunchman; Sep 16 '08, 07:06 AM. Reason: Added [Code] Tags - Please use the '#' button
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    let me know if this helps.

    Jared

    Comment

    Working...