Ted:
No, I think you've found one of those genuine "BUGS" in Visual FoxPro, rare as hen's teeth.
It's one of the only ones I've ever encountered!
Or you could build the logic directly into the INSERT INTO... SELECT statement, though it may get long and unwieldy.
This is what I wanted to avoid!
Scan the result of AFIELDS() and built a set of ColumnName-AliasName field, testing for the bad situations you've identified (integer first character, excessive length, and also duplication, since you're truncating) and then build the field list using textmerge or string concatenation as:
SELECT ColumnName as AliasName, ColumnName as AliasName, ColumnName as AliasName, ...
I think you hit on exactly what I was looking for because this will easily and quickly transfer the data from the remote cursor to the new fieldname list that I can use to create a brand new compliant cursor.
I think this new logic will work for any situation and provide a nice place to hook in other fixes later if they are needed.
SQLEXEC(m.lnSQL,[SELECT ] + m.tcExcelFieldList + [ FROM "] + m.tcSheet + ["Where ] + m.tcExcelWhereExpr, m.lcSQLAlias) AFIELDS( laArrayName, m.lcSQLAlias) FOR...NEXT through laArrayName to create lcCorrectedFieldList SELECT &lcCorrectedFieldList From m.lcSQLAlias into cursor m.lcNewSQLAlias USE (m.lcSQLAlias) m.lcSQLAlias = m.lcNewSQLAlias
Paul
[excessive quoting removed by server]