Microsoft KB Archive/197809

= INFO: Turn Off the Use of Temporary Stored Procedures with SQL Server =

Article ID: 197809

Article Last Modified on 3/2/2005

-

APPLIES TO


 * Microsoft Transaction Services 1.0
 * Microsoft Transaction Services 2.0
 * Microsoft SQL Server 6.5 Standard Edition

-



This article was previously published under Q197809



SUMMARY
When using SQL Server version 6.5 with Microsoft Transaction Server (MTS), it is important to turn off the use of temporary stored procedures for prepared SQL statements.

NOTE: The information in this article applies only to SQL Server 6.5.



MORE INFORMATION
Prepared SQL statements are executed using the SQLPrepare and SQLExecute ODBC API functions. ADO and RDO make extensive use of prepared statements in certain circumstances. SQL Server will create temporary stored procedures when executing prepared SQL statements if the database connection is configured to do so. This can cause undesirable side effects when SQL Server is used with MTS. To prevent this you must either:  Use a DSN with the "Create temporary stored procedures for prepared SQL statements" option turned off.

-or-  Include the "UseProcForPrepare=No" in your connection string for DSNless connections as in the following example:

Note You must change UID= and PWD= to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation on the database. driver={sql server}; server=myserver; UseProcForPrepare=No; database=pubs,UID= ,PWD= " Note that the above string should be included on one line; it has been wrapped for readability. 

The use of temporary stored procedures for prepared SQL statements may have the following unwanted effects:
 * The temporary stored procedures can accumulate on the server because they are often not destroyed until a connection is closed. Transaction Server uses ODBC connection pooling and connections can remain open for an extended period of time. Temporary stored procedures are stored in SQL Server's tempdb database. Over time, these temporary stored procedures can fill up tempdb and cause queries to fail. When tempdb is filled up you will receive a SQL Server error 1105.
 * The creation of stored procedures within transactions may cause blocking problems that can seriously affect concurrency. The creation of stored procedures causes SQL Server to lock data pages in several system tables for the duration of the transaction. Other transactions that try to create stored procedures will then be blocked until the first one has completed. If you have composed your MTS activity to include more than one transaction, these transactions may block each other until they time out.

Keywords: kbinfo kbdatabase KB197809

-

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

© Microsoft Corporation. All rights reserved.