Microsoft KB Archive/70673

= PRB: Process All Results to Find Number of Rows Affected =

Article ID: 70673

Article Last Modified on 2/14/2005

-

APPLIES TO


 * Microsoft SQL Server 4.21a Standard Edition
 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 7.0 Service Pack 1

-



This article was previously published under Q70673



SYMPTOMS
In a DB-Library (DB-Lib) application that performs SELECT statements that return large numbers of result rows, the following procedure is being used to find out how many rows are returned without processing the entire query.

If a SELECT statement is performed by calling the DBSQLEXEC and DBRESULTS functions, and then calling the DBCANCEL function to cancel the query without processing the rows, a subsequent call to the DBCOUNT function returns an incorrect number of rows.



CAUSE
This functionality is not supported by the Microsoft SQL Server and DB-Library.



WORKAROUND
In the case above, the number of rows returned by DBCOUNT is the number of rows that were sent to the workstation before the query was canceled. This also occurs in SAF when the F6 key, which aborts processing of the query, is pressed before the query completes. A subsequent &quot;SELECT @@rowcount&quot; shows the number of rows sent to the workstation before the query was aborted.

To find the number of rows that would be returned without looping through each row in a DB-Lib application, issue the command &quot;SELECT COUNT(*)&quot; with the same WHERE clause as the original SELECT statement. This command is faster than processing each row, because only one row is returned from the SQL Server.

Additional query words: dblib Windows NT

Keywords: kbprogramming KB70673

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.