| Author |
SQL Server limiting result set
|
Ali Ekber
Ranch Hand
Joined: Jun 12, 2005
Posts: 41
|
|
|
I need to limit the result set coming from a SQL Server query. I can get the top 10 by SELECT TOP 10. But how do I get the rows from 11 to 20, for example? This is very easy in MySQL, but don't know the syntax for SQL server. Is this possible without stored procedures? Thanks.
|
 |
Amy Medrat
Greenhorn
Joined: Mar 05, 2006
Posts: 15
|
|
Hey Ali, I hope this would help select * from tableName where rowid in (select rowid from tableName where rownum < 21 minus select rowid from tableName where rownum< 11)
|
medRat
|
 |
Ali Ekber
Ranch Hand
Joined: Jun 12, 2005
Posts: 41
|
|
|
Amy, what are rowid and rownum? Are they keywords in SQL server? I am getting syntax error for them.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
No, but they are in Oracle. That query won't run in SQL Server.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
chien ajax
Greenhorn
Joined: Aug 22, 2005
Posts: 1
|
|
Get the rows from 21 to 30 in MSSQL Perfect Version [ March 10, 2006: Message edited by: chien ajax ]
|
 |
 |
|
|
subject: SQL Server limiting result set
|
|
|