[Pugged] There is no LIMIT to MS-SQL
Tim Perdue
ciapug@ciapug.org
Thu, 10 Oct 2002 18:11:09 -0500
You might look into "Cursors". It's been a while, but that's how we abstracted
this all away in oracle. There's something along the lines of fetch_forward or
something like that, once you've got yourself a cursor.
Similar thing probably in MS-SQL.
Tim
On Thu, Oct 10, 2002 at 10:54:19PM -0000, dave@visionary.com wrote:
> A while back we had a discussion about paginating results. Tim pointed out that you can use the LIMIT clause like so:
>
> "SELECT * FROM mytable WHERE column_x = $y LIMIT $nStart, $nEnd"
>
> This is really handy, except... it's not supported in all SQL servers, only mySQL (and maybe PostgreSQL? Others?). Neither Oracle or MS-SQL support it. :(
>
> In Oracle there are some fun ways around it using the record index #'s.
>
> Not in MS-SQL - I did a bit of looking around... people mostly have kludgey work arounds for it. Using the "TOP" clause, you can save yourself from having to get the entire record set... but you still have to loop down to the starting record, as far as I can tell.
>
> Not a major problem - in the specific case I'm working on there's only a few hundred records max in the result set. But... if you had millions of records, I suppose you'd have to write some spiffy stored procedure to handle it?
>
> -dc
>
> _______________________________________________
> Ciapug mailing list
> Ciapug@ciapug.org
> http://cialug.org/mailman/listinfo/ciapug
--
Founder - PHPBuilder.com / Geocrawler.com / SourceForge
GPG Public Key: http://www.perdue.net/personal/pgp.php
Perdue, Inc. / Immortal LLC
515-554-9520