SQLDescribeCol
For executed statements, the SQL Native Client ODBC driver does not need to query the server to describe columns in a result set. In this case, SQLDescribeCol does not cause a server roundtrip. Like SQLColAttribute and SQLNumResultCols, calling SQLDescribeCol on prepared but not executed statements generates a server roundtrip.
When a Transact-SQL statement or statement batch returns multiple result row sets, it is possible for a column, referenced by ordinal, to originate in a separate table or to refer to an entirely different column in the result set. SQLDescribeCol should be called for each set. When the result set changes, the application should rebind data values prior to fetching row results. For more information about handling multiple result set returns, see SQLMoreResults.
The SQL Native Client ODBC driver uses the SET FMTONLY statement to reduce server overhead when SQLDescribeCol is called for prepared but not executed statements. Column attributes are reported for only the first result set when multiple result sets are generated by a prepared batch of SQL statements.
For large value data types, the value returned in DataTypePtr is SQL_VARCHAR, SQL_VARBINARY, or SQL_NVARCHAR. A value of SQL_SS_LENGTH_UNLIMITED in ColumnSizePtr indicates that the size is “unlimited”.
See Also
Concepts
ODBC API Implementation Details