Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Unanswered: Fetch limited rows sequentially

    Hello Friends,
    I want to fetch limited rows from single query (example:-1000 rows present in emp table , I want to fetch first 10 rows at a time and store in a file. Next iteration it has to fetch next 10 rows and store in another file like this it has to create 10 different files with 10 rows)
    Thanks in advance
    Waiting early reply
    Regds
    Nitin

  2. #2
    Join Date
    Oct 2003
    Location
    Sweden
    Posts
    45
    Hi Nitin,
    Code:
    SELECT * 
    FROM (SELECT TOP 10 * 
    	FROM (SELECT TOP 20 * 
    		FROM emp 
    		ORDER BY LName ASC) AS t1 
    	ORDER BY LName DESC) as t2 
    ORDER BY LName
    This select will return the 10 after the first ten from emps table. Just loop through increasing the TOP 20 to TOP 30 and so on to get each interval of ten employers.

    Hope this helps!
    Robert

Posting Permissions

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