FIX: Failed Sp_prepare Incorrectly Closes Transaction

This article was previously published under Q198265
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 53474 (SQLBUG_70)
SYMPTOMS
Failure to prepare a statement, either by means of ODBC or OLE DB,incorrectly results in the failure of the entire transaction. Potentialcauses for such a failure include syntax errors or incorrect object namesin the statement. Subsequent operations that depend on the transactionbeing active, including attempts to commit the transaction, will fail.
CAUSE
SQL Server incorrectly closes the whole transaction after any error, ratherthan stopping execution of the statement only.
WORKAROUND
To work around this problem, execute the statement without first preparingit, using SQLExecDirect or ICommandText::Execute. An error during either ofthese operations will cause only the statement, rather than the whole thetransaction, not to be processed. The application can then determine theappropriate response, such as ignoring the error and continuing with otherstatements, resubmitting the query without the problem, or rolling back thetransaction.
STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 1 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
232570INF: How to Obtain Service Pack 1 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.
MORE INFORMATION
Attempts to commit or roll back the transaction after it has beenprematurely closed may result in the following errors:
Msg 3902
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.

Msg 3903
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.

You may also encounter other errors that are not obviously related. Forexample, non-static cursors are closed when a transaction is rolled back;thus, if the application had previously opened such a cursor as part ofthis transaction, it will be closed, and attempts to fetch from or closethis cursor would result in various errors indicating that the cursor isnot open.

@@trancount xact abort sp_prepare rollback terminate aborts terminates aborted terminated oledb
Properties

Article ID: 198265 - Last Review: 10/11/2013 18:17:38 - Revision: 2.1

  • Microsoft SQL Server 7.0 Standard Edition
  • kbnosurvey kbarchive kbbug kbfix kbqfe KB198265
Feedback