Microsoft KB Archive/101520
Article ID: 101520
Article Last Modified on 7/30/2001
This article was previously published under Q101520
SQLDescribeCol in the ODBC API and SAG's Call Level Interface Specification is intended to return meta data about a column in a results set. However, it does not return table names as part of this meta data. This article discusses how this limitation stems from SQL92, and also how applications can work around this limitation.
SQLDescribeCol returns the column names of the results set in szColname. However, when two columns in a results set have the same name (for example, by a join between 2 tables), it does not return the table name along with the column name to differentiate the two similarly named columns.
This limitation arises from SQL, more specifically SQL92, which addresses this issue in Subclause 7.4, Syntax Rule 1b) on the 'From Clause':
Given the above rule, the following SQL example should clarify this:
// Table1 has a column 'address', and so does Table2 select * from Table1, Table2
The 'address' column can be differentiated as being from Table1 or Table2 depending on its position in the results set. The 'address' column from Table1 will always come before the 'address' column in Table2.
Additional query words: 1.00