Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Posts
    18

    Question Unanswered: How to fetch limited record from DB (SQL Server)

    Hi,

    I have 20,000 records in a table, and i want to retrieve only 1- 20 records from the table.How can v specify the range.

    we can achieve this in oracle using the ROWNUM like the follwing query.
    "select * from tblPerson where ROWNUM>1 and ROWNUM<20".

    Is there any way to get the same in SQL Server7.0.

    If possible, please let me know.

    Thanx.
    Kishan

  2. #2
    Join Date
    May 2002
    Location
    Timbaktu
    Posts
    185
    I guess your back ground is Oracle..

    There are two ways to do this in Sql Server:
    1. Set Rowcount 20
    Select * from tblperson
    2. Select Top 20 * from tblperson


    Hope it helps

  3. #3
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249
    Set Rowcount 20
    changes behavior of your connection. Now all can do max 20 operations in each select,update,....
    Do not forget to clean up by
    Set Rowcount 0

Posting Permissions

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