TechNet
Export (0) Print
Expand All

SQLDescribeCol

 

System_CAPS_ICON_warning.jpg Warning

SQL Server Native Client (SNAC) is not supported beyond SQL Server 2012. Avoid using SNAC in new development work, and plan to modify applications that currently use it. The Microsoft ODBC Driver for SQL Server provides native connectivity from Windows to Microsoft SQL Server and Microsoft Azure SQL Database.

For executed statements, the SQL Server 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 SQLColAttributeandSQLNumResultCols, 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.

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”.

Improvements in the database engine starting with SQL Server 2012 allow SQLDescribeCol to obtain more accurate descriptions of the expected results. These more accurate results may differ from the values returned by SQLDescribeCol in previous versions of SQL Server. For more information, see Metadata Discovery.

The values returned for date/time types are as follows:

DataTypePtrColumnSizePtrDecimalDigitsPtr
datetimeSQL_TYPE_TIMESTAMP233
smalldatetimeSQL_TYPE_TIMESTAMP160
dateSQL_TYPE_DATE100
timeSQL_SS_TIME28, 10..160..7
datetime2SQL_TYPE_TIMESTAMP19, 21..270..7
datetimeoffsetSQL_SS_TIMESTAMPOFFSET26, 28..340..7

For more information, see Date and Time Improvements (ODBC).

SQLDescribeCol supports large CLR user-defined types (UDTs). For more information, see Large CLR User-Defined Types (ODBC).

SQLDescribeCol Function
ODBC API Implementation Details

Community Additions

ADD
Show:
© 2016 Microsoft