Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Location
    India
    Posts
    3

    Question Unanswered: Paging of Records from SQL QUERRY

    Hi all,

    I have a stored procedure which takes 4 parameters

    @Page Numeric, @Size Numeric, @SQL VARCHAR(75), @COUNT = 0 NUMERIC OUTPUT

    In @SQL variable a SQL querry is passed on which I don't know. Based on this sql querry page and the size I have to return the recordset with limited records and total rows in the fetched from SQL Querry as OUT parameter. Please help me out.

    Thanx in advance

    Amit
    Last edited by amitarora7; 09-30-03 at 07:06.

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Paging of Records from SQL QUERRY

    I was doing paging like this:

    -SP does have parameters - show page#, lines per page;
    -create temporary table with identity;
    -insert data to temporary table (include sorting);
    -select and return page (not big deal if you know page# )
    - select and return totals for columns (if it needs)
    - output parameter- total pages.

    It is very simple and very effective method (it does have potential problems but it works for many cases).

  3. #3
    Join Date
    Sep 2003
    Location
    India
    Posts
    3

    Paging in recordset

    Hi Snail,

    Thank you for your reply. But I think one thing you are missing is that we have a dynamic querry. So please consider this point and help me out.

    --Amit

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Paging in recordset

    Originally posted by amitarora7
    Hi Snail,

    Thank you for your reply. But I think one thing you are missing is that we have a dynamic querry. So please consider this point and help me out.

    --Amit
    I had dynamic query too. I will try to find code for this sp and post it.

    Anyway check this query - how it is possible to create temporary table:

    SELECT *,IDENTITY(int, 1, 1) AS newid
    INTO #tmp
    FROM sysobjects

  5. #5
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Paging in recordset

    Check this code: sp and asp page with paging. It is a little complicated but you could find the main idea.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •