none
Select a Group of Records of a table RRS feed

  • Question

  •  

    i want to write a store prosedure that select for example 1..n records of table

    how can i do it?

    best regards

     

    Sunday, September 16, 2007 11:55 AM

Answers

  • No, but i can teach you how to do a websearch so that you find the answer yourself... Just type "paging with sql server 2005" and you will find many valuable resources.. (the other keyword you could use is "pagination" instead of paging...)
    Monday, September 17, 2007 12:26 PM

All replies

  • First, in order to select the first n rows, you need to have an order relationship (otherwise, how would you define which is 1 and which is n?), so you will have to think about an ORDER BY statement.

    Second: which SQL-dbms are you using? Since each dialect has it's own variant, eg:

    SQL Server -> TOP
    Oracle -> %ROWNUM
    MySQL -> LIMIT
    PGSQL -> LIMIT
    Sunday, September 16, 2007 3:08 PM
  • thank you timvw

    i am using Sql Server 2005.

    in addition for example we have table i want to get data in paging(each time only get 20 records from table)

    can you write T-Sql  example for me please

     

     

    Monday, September 17, 2007 11:29 AM
  • No, but i can teach you how to do a websearch so that you find the answer yourself... Just type "paging with sql server 2005" and you will find many valuable resources.. (the other keyword you could use is "pagination" instead of paging...)
    Monday, September 17, 2007 12:26 PM