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)
 display top records

Author  Topic 

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2011-02-02 : 14:10:02
Hello Guys,

I have a question, if i have 1000 records in a database. How do i list at a time 200 data.

eg.
select top 200 * from tbl1

how do i desplay 201 to 400 records?

Dennis Falls
Starting Member

41 Posts

Posted - 2011-02-02 : 16:05:49
create a temp table that has RecID as an Identity column
insert into the temp table sorted by whatever column makes sense for your top
select from temp table where RecID BETWEEN n and n
Go to Top of Page

sathishmangunuri
Starting Member

32 Posts

Posted - 2011-02-02 : 23:54:43
or

you can use ROW_NUMBER()

sathish
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-03 : 03:19:54
Refer method 4
http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -