Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Row Range

Author  Topic 

irfanshirur
Starting Member

21 Posts

Posted - 2009-06-10 : 07:28:49

Hello

Is there any keyword which will accept row range in query ?

select top 100 * from Table, will retirve the first 100 records.

Like that if i want to retrive 100-200 rows then ?

Please can any one help me out for this solution.

Thanks in Advance

companionz
Yak Posting Veteran

54 Posts

Posted - 2009-06-10 : 07:43:13
In your data retreival select query include this function too:

Row_number() OVER(ORDER BY table_primary_key) AS RowNumber

Example:

With temp_table
as (select field_name, Row_number()
OVER(ORDER BY primary_key) AS RowNumber
from table_name)
select field_name from temp_table
where RowNumber between 100 and 200


Try this out..

Sourav
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-10 : 07:43:25
It's called pagination and it is not handled gracefully in SQL Server.
MySQL has the LIMIT keyword, but SQL Server doesn't.

There are many examples of pagination here at SQLTeam.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

irfanshirur
Starting Member

21 Posts

Posted - 2009-06-10 : 07:55:37

Hi Guys

Thanks a Lotttt i got the output.

Go to Top of Page
   

- Advertisement -