If you want to be able to restrict the number of rows returned from a query
to a MS SQL Server database then you can use the "set rowcount xx" command.
This command can be used as follows to return 100 rows from a query:

set rowcount 100

select * from mytable where myvariable = 'mycriteria';

set rowcount 0

The set rowcount command affects all queries executed after the command.
Hence the set rowcount 0 is required to return things to normal.

Stephen Welds

----- Original Message -----
From: "Mindaugas Idzelis" <[EMAIL PROTECTED]>
To: "struts" <[EMAIL PROTECTED]>
Sent: Friday, June 15, 2001 12:57 PM
Subject: General DATABASE programming question


> This may be a little off topic, please forgive me. One of my
webapplications
> displays a group of results from a database query. These can be hundreds
of
> rows long. I would like to break these up into smaller sections to fit on
a
> page.
>
> My problem is, I don't want to run the entire query at once and save it to
> memory.
>
> PostgreSQL and MySQL have the LIMIT num,offset qualifier which does
exactly
> what I want. The problem is that I'm using MS SQL and it doesn't use the
> LIMIT keyword. Instead, it uses TOP and you can't supply an offset.
>
> My quetion: Is there anyway to specify an offset into a query using MS SQL
> Server? Thank you.
>
> --min
>

Reply via email to