Microsoft KB Archive/321842

= PRB: Meta Data ODBC Calls Fail on SQL Server Queries with Parameter Markers in Sub-Selects =

Article ID: 321842

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft ODBC Driver for Microsoft SQL Server 1.0
 * Microsoft ODBC Driver for Microsoft SQL Server 2.0
 * Microsoft ODBC Driver for Microsoft SQL Server 2.5
 * Microsoft ODBC Driver for Microsoft SQL Server 2.65
 * Microsoft ODBC Driver for Microsoft SQL Server 3.7
 * Microsoft ODBC Driver for Microsoft SQL Server 3.7
 * Microsoft ODBC Driver for Microsoft SQL Server 3.0
 * Microsoft ODBC Driver for Microsoft SQL Server 3.5
 * Microsoft ODBC Driver for Microsoft SQL Server 3.6
 * Microsoft ODBC Driver for Microsoft SQL Server 3.7

-



This article was previously published under Q321842



SYMPTOMS
ODBC application programming interface (API) calls such as SQLDescribeCol, SQLDescribeParam, and SQLNumResultCols, that retrieve meta data, fail when an application tries to use the calls with Microsoft ODBC Driver for SQL Server on parameters that are part of the subqueries.



CAUSE
The driver does not retrieve information for parameters that are not bound in subqueries.



STATUS
This behavior is by design.



MORE INFORMATION
SQLNumResultCols returns an incorrect column count, and SQLDescribeCol returns an error similar to the following:

[Microsoft][ODBC SQL Server Driver]Prepared statement is not a cursor-specification

If the parameters have been bound by the application through the SQLBindParameter API, the driver uses that information and the meta data calls do not fail.

To reproduce this behavior from the ODBC Test tool, follow these steps:

 Connect to the NorthWind database in SQL Server.  Call SQLPrepare on the following line of code: select T1.EmployeeID as c1 from (select * from EMPLOYEES where EMPLOYEES.EmployeeID  = ?) T1                    

Note that SQLNumResultCols returns 0 instead of 1. If SQLBindParameter was called before SQLNumResultCols, the correct column count is retrieved.

