Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Query

Status
Not open for further replies.

shultz

Programmer
Oct 28, 2001
42
HK
Is it possible to return rows from a certain number to certain number.

For example,
I give a SQL Statement as
Select * from tblTest

which gives me all the entries. Now I want to select the records from entry 20 to entry 30. Is it possible??

I know the statement

Select top 10 * from tblTest

gives me the first 10 records. But I want to do it from 10 to 20 etc.

Thanks in advance ..!!
 
Hi Shultz,
I have given the following query based on the Northwind database, you replace the tablename and columns with appropriate names.


select Top 10 * from Orders
Where OrderID Not In
(Select Top 10 OrderID from Orders Order By OrderID)
Order By OrderId


-Mukund.
 
hello mukund..

I think I was not clear...

I'm want something like for example.. tek-tips site.. where you display 10 entries at a time and on the next click you show the next 10 entries..

is it possible something like that in SQL Server. I mean I want to pass the number of records to fetch and from which record number..

any ideas??

thanks a lot
 
Check the following links.

Managing Result Set Paging:

Paging: Use ADO, getrows, or a Stored Procedure?

Paging through Records using a Stored Procedure:
Terry L. Broadbent - DBA
SQL Server Page:
If you want to get the best answer for your question read faq183-874.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top