MSQUERY: "Syntax Error" Occurs Using Field Name AliasesID: Q134685
|
In Microsoft Query, you may receive an error message similar to one of the following when you run a Structured Query Language (SQL) SELECT statement from the Execute SQL dialog box
where:Syntax Error.
SELECT <tablename>.<fieldname> '<aliasname>'<< ??? >> FROM <tablename>
Syntax error in query expression.
This behavior occurs because Microsoft Query has its own parse engine.
This parse engine processes SQL statements for database management systems
(DBMSs), or back-ends, that do not support certain SQL syntax. When you
run a query via the Execute SQL dialog box, it bypasses the Microsoft Query
parse engine and sends the SQL statement directly to the Open Database
Connectivity (ODBC) Driver Manager. If the ODBC Manager does not
understand the syntax of the SQL statement, it passes it on to the DBMS.
Database back-ends, such as Microsoft SQL Server, that can process SQL
statements in this manner will have no problem accepting them. However,
with other DBMS, such as dBASE, this situation will cause an error and you
must use the alternative method described in the "Resolution" section of
this article (below).
To resolve this situation, use syntax similar to the following example when
you run a query from the Execute SQL dialog box:
SELECT customer.CUSTMR_ID AS "Customer Id" FROM customer
Field name aliases let you provide a different name for a field heading.
For example, to return the CUSTMR_ID field from the CUSTOMER table as
"Customer Id," Microsoft Query creates a SELECT statement as follows:
SELECT customer.CUSTMR_ID 'Customer Id' FROM customer
For more information on creating a query using the Execute SQL command:
Additional query words:
Keywords : kbinterop kbtool xlquery
Version : 1.0 2.0
Platform : WINDOWS
Issue type :
Last Reviewed: July 29, 1999