Monday, March 12, 2012

Paging of Records

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

AmitI 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).|||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|||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|||Check this code: sp and asp page with paging. It is a little complicated but you could find the main idea.

No comments:

Post a Comment