Help needed limiting recordsets

Help needed limiting recordsets

Post by CRB » Wed, 12 Dec 2001 05:01:29



Hi All,

I want to limit the number of rows returned by a
select statement. For instance, I would like to be able to
retrieve the records from a select statement in blocks of, lets say
100 records: the first select would return the records 1 to 100,
the second, records 101 to 200, etc.

I know that Oracle has a "rownum" expression that we can use in
a where clause, but could not find anything similar for sql server.

Thanks
CD

 
 
 

Help needed limiting recordsets

Post by oj » Wed, 12 Dec 2001 05:17:35


cd,

there is no such thing as 'rownum' in sqlserver. tables are unordered in
sql.

here is an alternative...

select *, pkid=identity(int,1,1)
into #tmp
from tablename
order by [whatever your want]

select *
from #tmp
where pkid between 101 and 150

-oj


Quote:> Hi All,

> I want to limit the number of rows returned by a
> select statement. For instance, I would like to be able to
> retrieve the records from a select statement in blocks of, lets say
> 100 records: the first select would return the records 1 to 100,
> the second, records 101 to 200, etc.

> I know that Oracle has a "rownum" expression that we can use in
> a where clause, but could not find anything similar for sql server.

> Thanks
> CD


 
 
 

1. help:resource limit reached for recordsets

Hi.

I'm writing an application that unfortunately needs to have several
recordsets open concurrently, that each are of a considerable size.
Trying to open them all gives me an error message:

IDispatch #3121
-2147217871
Execution aborted because a resource limit has been reached.  no results
have been returned.

Any knowledge as the source of this error would be greatly appreciated.
Any solution to this problem would be very much appreciated.

Thank you,

Matt Bowen

2. 6.5 data comparison software

3. Need help limiting No. selection in VB5

4. Microsoft Data Link Erro

5. Need Help Limiting Body Part

6. Strange Update results

7. Need help limiting access to database.

8. Tracing ODBC

9. Help Needed to Limit Access to Valid Nodes on NT for Specific SID

10. URGENT, NEED HELP (SSL and 2GB RAM memory limit)

11. Forms and Code limit Help- General Information Needed

12. URGENT help please - need to limit results with multi table join

13. Need help to read comma delimited file to ADO recordset