Retriving Rows between m and n

  •  Hey

    How can i retrive rows between m and n (10 -20).  I already have identity column in the table, that will not give results insequential order for given select queries. I can get row number as below ...      

    WITH ONE_MIL_t AS

    (SELECT * , ROW_NUMBER() OVER (order by abc, startdate)as RowNumber

    FROM ONE_MIL )

    SELECT *

    FROM ONE_MIL_t

    where RowNumber between 20 and 100000 ;

       Can i get resulset using cursors. Will cursor give same performance like above or ??? Regards

    Shrikant

    Regards
    Shrikant Kulkarni

  • Hello,

    I would not recommend using cursors for this. SQL is a set based language and the relational database engine inside SQL Server is optimized for handling SETs. I am not saying that cursors are always slower then using SETs, it of course depends on how you use them and the situations you apply your cursors on.

    Try searching this forum for PAGING which is probably what you would like to know more about.

    Regards, Hanslindgren

Viewing 2 posts - 1 through 1 (of 1 total)

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