[thelist] SQL Rowcount Problem

Howard Cheng howcheng at ix.netcom.com
Fri Jun 21 14:30:01 CDT 2002


I think the easiest thing to do would be two queries, joined by a UNION
statement.

SELECT COUNT(*), null, null, null, null FROM mytable
UNION ALL
SELECT TOP 50 a, b, c, d, e FROM mytable

At 02:12 PM 6/21/2002 -0500, Seth Bienek wrote:
>I have a query (SQL Server, CF5) that returns up to several thousand
>rows as a search result.  Due to the nature of the query, at times it
>runs long, and adding to the performance issue (I believe) is the fact
>that it returns many columns and many rows of data from the SQL Server
>via the network, when I only need to display a few at a time (10-50) to
>the user.
>
>I need to pull all the rows in order to return the number of matches,
>right?  Is there a way to avoid having to handle all the data (and it's
>overhead) when I only really want the first x rows and a count of the
>total number of matches?
>
>I can use the TOP operator, but it of course returns as the recordcount
>only the number of rows returned..  I know there's a way around this,
>but the documentation doesn't seem to be much help to me thus far..
>
>Any help is greatly appreciated!

::::::::::::::::::::::
Howard Cheng
howcheng at ix.netcom.com
AIM: bennyphoebe
ICQ: 47319315




More information about the thelist mailing list