in reply to Limit results of a DBI query

I think MS-SQL server understands the TOP directive, as in
select TOP 10 distinct country ...
Alternatively, issue a
$dbh->do("set rowcount 10");
first. This will limit all queries to 10 rows returned on that connection, until it is reset. You set it back to "unlimited" with
$dbh->do("set rowcount 0");
Michael

Replies are listed 'Best First'.
Re: Re: Limit results of a DBI query
by peppiv (Curate) on Jan 28, 2003 at 16:53 UTC
    Thanks for the help.

    The TOP 10 command didn't work and I've tried putting the "set rowcount" statement in various places but I couldn't get it to work either.

    Any other ideas?

    peppiv

      The "set rowcount" directive applies to physical connection. If for some reason the $dbh->do() command opens a new connection under the covers then it won't work.

      Which DBD driver are you using?

      Michael

        I'm running an Apache/Linux server using FreeTDS and dbi:Sybase (Thank you) connecting to a Win2K box with MSSQL 7.0. Took a little while to get this all talking.

        peppiv