/ MS SQL Server 2003

Results 1 to 2 of 2

Thread: / MS SQL Server 2003

  1. #1
    Join Date
    Dec 1969

    Default / MS SQL Server 2003

    I am currently writing a script that must paginate a large table into groups of whatever number specified by the user. This table contains items of different categories, each category designated a number.<BR><BR>Thus, if I were to return all items from category two I would use the following SQL Statement:<BR><BR>SELECT * FROM TABLE WHERE CATEGORY = 2<BR><BR><BR>I could also order the results by any column I wished. Every record has a unique ID column (named "ID"). However, each category does not have its own index; there is only one index for all categories.<BR><BR>I need to be able to retrieve any page number of any category from this table, possibly treating each category as if it were its own table, without actually creating a separate table for each one. Temporary tables and stored procedures are acceptable, provided an example SQL statement is included showing how to execute it. However, an SQL statement alone is preferred.<BR><BR>It is not acceptable to return more records than are required to view the page. For example, if only 10 records are to be visible at once, then only 10 records may be queried. And I need to be able to pass the page number, not a primary key index into the query.<BR><BR>Essentially, something like this would be ideal:<BR><BR>EXECUTE PROCEDURE GetPageRows(TableName, FilterString, RowsPerPage, PageNumber)<BR><BR><BR>FilterString would contain something like "CATEGORY = 3" or "FILTERCAT=400" since the column name I will need to distinguish will change between tables; the table name also needs to remain variable.<BR><BR>Thank you very much in advance.<BR>-Jeff

  2. #2
    Join Date
    Dec 1969

    Default I just posted an answer at

    This is _extreme_ cross-posting - If you want a quick answer without tying up multiple people, please stick to one place, otherwise people on different sites will be effectively duplicating their efforts when they could be helping someone else.<BR><BR>sure, today is a slow day, but the point stands.<BR><BR><BR>j<BR>

Posting Permissions

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