Results 1 to 5 of 5

Thread: about the cursor

  1. #1
    Join Date
    Oct 2002
    Location
    china
    Posts
    2

    Question about the cursor

    Please give me the answer.
    (The requirement: fetch 1000 rows)
    I don't know whether the 'DECLARE CURSOR' statement supply a parameter to define the '1000' or not.

  2. #2
    Join Date
    Oct 2002
    Posts
    1
    is it possable for you to do record count and then set up a for loop with a count up to 1000 every time the cursor is executed add 1 to the count.

  3. #3
    Join Date
    Oct 2002
    Location
    china
    Posts
    2

    Smile thanks

    Thank you for your reply.But this is not the answer that I want! I just need to avoid the loop!

  4. #4
    Join Date
    Nov 2002
    Posts
    8
    If you simply want to retrieve 1000 rows try using :

    select top 1000 field_name
    from table_name
    order by your_criteria

    But if you actually want to pass 1000 rows through a cursor you could create an incrementing variable and stop the cursor when it reaches 1000.

  5. #5
    Join Date
    Nov 2002
    Location
    Chicopee, MA
    Posts
    12

    Fetch 1000 rows

    You should be able to limit the number of rows returned by issueing the following prior to your select statement:

    SET ROWCOUNT 1000

    This will return only 1000 rows.
    Steve Jimmo
    DBA
    Sybase, MS SQL Server

Posting Permissions

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