Excel ODBC Driver May Determine Wrong Data Type

This article was previously published under Q141284
This article has been archived. It is offered "as is" and will no longer be updated.
SYMPTOMS
When you use a Microsoft Excel worksheet as a data source in MicrosoftQuery, and you attempt to create a join between two fields of seeminglysimilar data types, Microsoft Query may generate the following warningmessage:
Columns <name> and <name> that you are about to join are of different types. Create the join anyway?
If you choose Yes to this option, you receive either of the followingerrors:

Microsoft Query version 1.0

Type mismatch.

Microsoft Query version 2.0

Reserved error(-3079); there is no message for this error.

Microsoft Query version 8.0

Type mismatch in JOIN expression.
This behavior occurs regardless of the number of "Rows To Scan" youspecified when you set up the data source.
CAUSE
This problem occurs because the two apparently similar fields may beevaluated as being of different data types. This difference in type causesan error and prevents you from completing the join.

The Microsoft Excel Open Database Connectivity (ODBC) driver providesan option called Rows To Scan. This option specifies the number of rowsto scan to determine the data type of each column. The data type isdetermined given the maximum number of kinds of data found. If data isencountered that does not match the data type guessed for the column,the data type will be returned as a NULL value. The ODBC.HLP fileincluded with the ODBC driver includes the following information:
For the Microsoft Excel driver, you may enter a number from 1 to 16 for the rows to scan; however, the value will always default to 1. (A number outside the limit will return an error.)
This information is incorrect. The Rows To Scan option will always usethe first eight rows of data to determine the data type of a givenfield regardless of the number of rows specified. In the case where thefirst 8 rows contain four numeric and four text values, the data typefor the column will default to Number.
WORKAROUND
To ensure that Microsoft Query accesses your Microsoft Excel data properly,make sure that all values in a particular column are of the same data type.Do not mix text and numeric data in a single column. If you need to havemixed data in a field, format the column in Microsoft Excel as Text (on theFormat menu, click Cells, and select the Text option on the Numbers tab)before you enter data.
STATUS
Microsoft is researching this problem and will post new informationhere in the Microsoft Knowledge Base as it becomes available.
REFERENCES
For more information about Rows To Scan, click Help in the Add DataSource dialog box. In ODBC Help, click the Index tab, and type thefollowing text:
rows to scan
ODBC 2.00 5.00c 8.00 97
Properties

Article ID: 141284 - Last Review: 12/04/2015 12:37:48 - Revision: 1.1

Microsoft Excel 97 Standard Edition, Microsoft Excel 5.0 Standard Edition, Microsoft Query 2000, Microsoft Open Database Connectivity Desktop Database Driver Kit 2.0

  • kbnosurvey kbarchive kbualink97 KB141284
Feedback