Microsoft KB Archive/884315

= The SQLDescribeCol command returns metadata for the last statement from the batch when executed on a prepared batch of SQL statements =

Article ID: 884315

Article Last Modified on 11/5/2007

-

APPLIES TO


 * Microsoft ODBC Driver for Microsoft SQL Server 2.5

-





SYMPTOMS
You receive the metadata for the last SQL statement from a batch of SQL statements when you run the SQLDescribeCol command on the prepared batch of SQL statements in the ODBC Test tool.



CAUSE
The ODBC driver overwrites the column information in the buffer. Therefore, the metadata is retrieved only for the last SQL statement from a prepared batch of SQL statements.



RESOLUTION
To resolve this problem, follow these steps to execute the prepared batch of SQL statements before running the SQLDescribeCol command.
 * 1) Start ODBC Test.
 * 2) Prepare the batch statement.
 * 3) On the Stmt menu, click SQLExecute.
 * 4) In the SQLExecute dialog box, click OK.
 * 5) On the Results menu, click SQLDescribeCol.
 * 6) In the SQLDescribeCol dialog box, click OK to see the result of first statement in the prepared batch statement.
 * 7) On the Results menu, click SQLMoreResults.
 * 8) In the SQLMoreResults dialog box, click OK.
 * 9) On the Results menu, click SQLDescribeCol.
 * 10) In the SQLDescribeCol dialog box, click OK to see the next result.



MORE INFORMATION
The problem exists in version 2000.85.1022 of the SQLSRV32.dll file. The SQLSRV32.dll file is the Microsoft SQL Server ODBC driver. Version 3.7 of the SQLSRV32.dll file shows the correct behavior when you run the SQLDescribeCol command.

Steps to reproduce the behavior
 Create a new SQL Server database and add new tables to it.  Open SQL Query Analyzer.  Run the following scripts in SQL Query Analyzer: Create database Test go   Run the following code in SQL Query Analyzer: use Test go drop table TSTSIMPLE go create table TSTSIMPLE( clef1 int, champ char(20)) insert into TSTSIMPLE values( 0, 'Microsoft SQL Server') insert into TSTSIMPLE values( 1, 'Un') insert into TSTSIMPLE values( 2, 'Deux') go drop table TSTDATE go create table TSTDATE(clef2 datetime, champ varchar(20)) go insert into TSTDATE values(getdate, 'I was here') go select * from TSTSIMPLE go select * from TSTDATE go   Create a Data Source Name (DSN).  In Control Panel, double-click Administrative Tools.</li> Double-click Data Sources (ODBC).</li> In the ODBC Data Source Administrator dialog box, click Add.</li> In the Create New Data Source dialog box, click SQL Server in the Select a driver for which you want to set up a data source list, and then click Finish.</li> In the Create a New Data Source to SQL Server dialog box, type in the Name box.

Note  is a placeholder for the DSN name that you want to create.</li> In the Server box, type, and then click Next.

Note  is a placeholder for the address of the SQL Server where you have created the database in step 1.</li> Click Next.

Note If you are using SQL Server authentication, type your username and your password in the LoginID and Password boxes, and then click Next.</li> Click to select the Change the default database to check box, select Test, and then click Next.</li> Click Finish. The ODBC Microsoft SQL Server Setup dialog box appears.</li> Click OK to close the ODBC Data Source Administrator dialog box.</li></ol> </li> Run the ODBC Test tool.  Start the ODBC Test tool.

Note You can run the ODBC Test tool by running the Odbcte32.exe file on your computer. The ODBC Test tool is also available in the Microsoft Data Access (MDAC) 2.8 Software Development Kit (SDK). To download the SDK, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=5067faf8-0db4-429a-b502-de4329c8c850&displaylang=en

</li> On the Conn menu, click Full Connect. The Full Connect dialog box appears.</li> <li>In the Data Source box, select or type the data source name that you created in the &quot;Create a Data Source Name (DSN)&quot; section, and then click OK.</li> <li> After you have successfully connected to the database, paste the following code in the Input window of the ODBC Test tool: select * from TSTSIMPLE select * from TSTDATE </li> <li>On the Stmt menu, click SQLPrepare.</li> <li>In the SQLPrepare dialog box, click OK.</li> <li>On the Results menu, click SQLDescribeCol.</li> <li>In the SQLDescribeCol dialog box, click OK. You notice the behavior that is mentioned in the &quot;Symptoms&quot; section.</li></ol> </li></ol>

The SQL batch prepare statement only shows the results of the second SQL statement. It does not show the results of the first SQL batch prepare statement.

<div class="references_section">