all groups > sql server msde > july 2005 >
You're in the

sql server msde

group:

Restricting Rows to be returned on Select


Restricting Rows to be returned on Select Arjang
7/29/2005 12:00:00 AM
sql server msde: Lets say Select * from Table returns 100 rows.
How can I get only get the
First 10 records , 2nd 10 records, etc ...
I now select Top n selects the top n rows from a query, but is there a
supported way of asking for next 20 rows after the row 50?

Thanks
Arjang

Re: Restricting Rows to be returned on Select Andrea Montanari
7/29/2005 12:00:00 AM
hi,
[quoted text, click to view]

paging is not directly supported as in (say) PostgreSQL which supprots
syntax like
SELECT select_list
FROM table_expression
[LIMIT { number | ALL }] [OFFSET number]

so you have manually create your filter criterion to exclude the TOP n rows
to reach the TOP n + m that meet your requirements...
different approaches have been seen... personally I like
http://www.windowsitpro.com/SQLServer/Article/ArticleID/16191/16191.html
http://www.windowsitpro.com/Article/ArticleID/44138/44138.html (subscriber
only)
http://weblogs.sqlteam.com/jeffs/archive/2004/03/22/1085.aspx
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.14.0 - DbaMgr ver 0.59.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply

AddThis Social Bookmark Button