Home > Archive > microsoft.public.sqlserver.server > December 2002 > SQL Command





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author SQL Command
Joe

2002-12-19, 11:23 am

Hello, I need help with this.
Suppose the following query returns 50 rows. Select State
from US order by State. If I want the first 10 to show,
set rowcount 10. If I want the 11th to 20th to show, what
should I do? In other word, is there an easy way in a
Store Procedure to show me 5 resultsets, of which with 10
records in alphabetic order? For now, what I can think of
is to use cursor to insert a record at a time to a temp-
table by looping the entire resultset, which I don't like
it due to performance. Thank you
Tibor Karaszi

2002-12-20, 5:23 am

Use TOP and ORDER BY. You can save the last returned value "in between" and use that in the
WHERE clause to get next x rows. There are other methods as well, so I suggest you search the
archives for things like "paging" for more info.

--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=...ublic.sqlserver


"Joe" <hdszfeng@aol.com> wrote in message news:054a01c2a77c$e7ea23e0$cef
82ecf@TK2MSFTNGXA08...
> Hello, I need help with this.
> Suppose the following query returns 50 rows. Select State
> from US order by State. If I want the first 10 to show,
> set rowcount 10. If I want the 11th to 20th to show, what
> should I do? In other word, is there an easy way in a
> Store Procedure to show me 5 resultsets, of which with 10
> records in alphabetic order? For now, what I can think of
> is to use cursor to insert a record at a time to a temp-
> table by looping the entire resultset, which I don't like
> it due to performance. Thank you



Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net