Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using COUNT with ROWCOUNT and TOP

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-28 : 23:36:26
Donald Sparks writes "I a query that will limit the number of record returned and also return the number of records returned in a variable in the recordset.

For Example:
If want a maximum of 100 records I would use

SELECT TOP 100 *
FROM MYTABLE
WHERE MYCONDITION = TRUE

or SET RECORDCOUNT 100 and drop the TOP 100.
The actual number of records where MYCONDITION from the table may vary say from 1 to 500. When I implement a COUNT I am receive the actual number of records instead of a number between 1 and my maximum of 100.

I have found a less desirable solution to this problem using the Row counter method discussed on this site but, it's too processor intensive as I only need the final count. Currently I resolve the issue in my ASP code but, I am being required to move the resolution into an SQL stored procedure with only a recordset as output.

Any suggestions?"
   

- Advertisement -