QueryTables.Add() not returning text from SQL Express table

D

D. Leger

Hello all,

Using Excel 2003 and SQL Server 2005 Express.

I have a simple database table with 3 fields:

Field_1: integer
Field_2: string
Field_3: decimal(4,2)

Using QueryTables.Add() in an Excel macro, I'm trying to retrieve one
record, i.e. one integer, one string and one decimal into cells. Strangely,
I'm getting the numbers back but not the string. The cell where the string
should appear is empty. I verified the SQL command and there is no error. The
string is properly queried along with the numbers.

In an effort to troubleshoot the problem, I tried importing the data
directly into a cell using Import External Data and I get the same results. I
can import any number from the database table but not the text. Weird.

Any ideas?

Thanks.

Daniel Leger
 
D

D. Leger

OK, the problem occurs if you declare your database field as Varchar(MAX).
The problem dissapears if the field is changed to a fixed length field, e.g.
Varchar(500).

D. Leger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top