Article ID: 253240 - Last Review: December 3, 2003 - Revision: 4.1 PRB: Errors Not Returned When Stored Procedure Statement FailsThis article was previously published under Q253240 On This PageSYMPTOMS
When executing a stored procedure with multiple queries (SELECTs, INSERTs and UPDATEs), the ActiveX Data Objects (ADO) errors collection appears not to be populated after an error occurs in the stored procedure. The stored procedure might also not return values from its RETURN statement.
CAUSE
The SQL Server OLE DB provider provides more accurate information (than ODBC) to the caller about what happened in the procedure. Each SQL statement within a stored procedure returns a "result," either a count of rows affected or a result set. You can walk through these result sets in ADO using the NextRecordset method on the Recordset object. The SQL Server ODBC provider, however, does not provide information about the results of individual SQL statements within a stored procedure. The only result that comes back from a stored procedure execution is the result of the SELECT statement, if it has one. This is why this problem may not manifest with ODBC. In both cases, return values from the stored procedure may not be returned. RESOLUTION
To resolve this problem, make sure that the SET NOCOUNT ON statement comes before any other SQL statements in the stored procedure, as in the following:
STATUS
This behavior is by design.
MORE INFORMATIONSteps to Reproduce the Behavior
APPLIES TO
| Article Translations
|
Back to the top
