need solution

  • hi

    i have 1,00,000 rows in table. i need values based on rows as

    in a loop:

    first one : i want query to display from 1 to 1000 values

    second one: next time to display 1000 to 2000 rows

    third time: to display 3000 to 4000 rows

    like that

    i want from 1 to 1,00,000 rows with limit 1000 rows.

    can any one help me on this

    Thanks and Regards

    ROCK.

  • I think what you want is a way of paging, but it's confusing because sometimes you're saying values and sometimes rows.

    You also need to decide if there is some order, or if you just need some 1000 rows.

    Try this article: http://www.sqlservercentral.com/articles/Advanced+Querying/3181/

  • I'd also like to see what you have done on your own first. We aren't here to write code on-demand, we are here to help people solve problems and gain a better understanding of SQL Server and the variety of components that make it up.

  • Presuming I understand you correctly, you need to get 1000 rows at a time - Have you Tried ROW_NUMBER()? You need something to order by though, and change the Between to range you want.

    SELECT

    *

    FROM

    (

    SELECT ROW_NUMBER() OVER(ORDER BY [ENTER Field to Order by Here]) AS 'Row', Fields... FROM [Table]

    ) AS X

    WHERE X.Row Between 1000 And 2000

  • hi justanewone ,

    thank you very much. i got it

    i have created a stored procedure, in that using the while loop and row_numbers() between values, it was solved my problem

    Lynn Pettis: i didn't look for complete solution man, to get some idea only.

    any ways thank you all

  • rockingadmin (6/22/2009)


    Lynn Pettis: i didn't look for complete solution man, to get some idea only.

    Not the impression I got from the title or wording of your original post.

    Still, I recommend when asking for help that you show what you have done in trying to solve your problem or issue instead of just asking for code.

    I would also recommend reading the first article I reference below in my signature block regarding asking for help. If you follow the guidelines outlined in that article you will also get much better answers to your questions.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply