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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Flowing Fount of Yak Knowledge

1274 Posts

Posted - 10/09/2006 :  04:10:59  Show Profile  Send sunsanvin a Yahoo! Message  Reply with Quote
hi friends,
i need a query to display the rows from 2 to 5 records.

suppose i have 100 records in my table.

i need records from 2 to 5 only.

thanks in advance

Patron Saint of Lost Yaks

30421 Posts

Posted - 10/09/2006 :  04:19:59  Show Profile  Visit SwePeso's Homepage  Reply with Quote
How do you determine row/record order?

Peter Larsson
Helsingborg, Sweden

Edited by - SwePeso on 10/09/2006 04:20:12
Go to Top of Page

Flowing Fount of Yak Knowledge

5581 Posts

Posted - 10/09/2006 :  04:36:12  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
Refer this article, point # 13:

Harsh Athalye
"Nothing is Impossible"
Go to Top of Page

Flowing Fount of Yak Knowledge

1907 Posts

Posted - 10/09/2006 :  05:47:52  Show Profile  Visit chiragkhabaria's Homepage  Send chiragkhabaria a Yahoo! Message  Reply with Quote
If you have primary key in your table, then have a look at the following script

SELECT        (SELECT COUNT(i.au_id) 
               FROM pubs..authors i 
               WHERE i.au_id >= o.au_id ) AS RowID, 
              au_fname + ' ' + au_lname AS 'Author name'
FROM          pubs..authors o

This will generate the RowId and then accordingly you can select the rows which you want sepcifying the range in the where clause.

if you are using SQL Server 2005 then have a look at following link.

Go to Top of Page

Premature Yak Congratulator

22864 Posts

Posted - 10/09/2006 :  09:35:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Do you need Pagination?


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

Not Just a Number

15586 Posts

Posted - 10/09/2006 :  09:58:33  Show Profile  Reply with Quote
The physical order of data in a database has no meaning

What purpose does it serve you to say you want rows 2 thru 5?

Tell us what value rows 2 thru 5 have, then we can help



Hint: Want your questions answered fast? Follow the direction in this link

Add yourself!

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000