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
 General SQL Server Forums
 New to SQL Server Programming
 Select top n rows

Author  Topic 

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2009-06-15 : 05:33:34
Hi all,

what is the query to select rows n to m
i mean for eg:
i need to select rows from 10 to 20

please someone help me

thanks


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-15 : 05:35:06
It's called pagination and there lot of examples here at SQLTeam.


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

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2009-06-15 : 05:41:03
actually n and m are not variables. i always use 10 to 20 in one query and 20 to 30 in another query.

Go to Top of Page

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2009-06-15 : 05:43:52
i think i got it..


SELECT TOP 10 START AT 10
NAME,
EMP NO
FROM TABLE



But START AT is not there in sql server 2005, am i right?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-15 : 05:52:22
Correct.
Also there is no LIMIT, as there is in MySQL.



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

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2009-06-15 : 06:02:25
but how do i do that
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-15 : 06:05:33
http://www.lmgtfy.com/?q=site%3Asqlteam.com+efficient+pagination


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

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-06-15 : 10:09:34
OMG that site is totally a.w.e.s.o.m.e.!!

- Lumbago
Go to Top of Page
   

- Advertisement -