ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Renaming columns in MS Query (https://www.excelbanter.com/excel-discussion-misc-queries/157456-renaming-columns-ms-query.html)

RhysPieces

Renaming columns in MS Query
 
I use several MS Queries to import into Excel '03 workbooks via ODBC from our
corporate mainframe (linked Access tables). I would like to rename the column
headings in the query design before returning the results to Excel. However,
despite the options to do so, I keep getting error messages about a 'missing
expected lexical'. I even tried editing the SQL statement but got the same
results. What's the trick to make MS Query rename the columns?

Duke Carey

Renaming columns in MS Query
 
At a guess, you're trying to use column names that have spaces. Enclose
those names within a pair of single quotes.

select lname as 'Last Name' from somedatabase



"RhysPieces" wrote:

I use several MS Queries to import into Excel '03 workbooks via ODBC from our
corporate mainframe (linked Access tables). I would like to rename the column
headings in the query design before returning the results to Excel. However,
despite the options to do so, I keep getting error messages about a 'missing
expected lexical'. I even tried editing the SQL statement but got the same
results. What's the trick to make MS Query rename the columns?


RhysPieces

Renaming columns in MS Query
 
This is an example of what I have : UnitofMeasure. What I want is UOM. There
are about 6 other columns but this is simply an example. If I can fix this
one the rest will be easy.

When using the suggestion below I get the error code: 'unexpected lexical
element missing:<identifier'. Please tell me what this means and a
work-around. Thanks again.

"Duke Carey" wrote:

At a guess, you're trying to use column names that have spaces. Enclose
those names within a pair of single quotes.

select lname as 'Last Name' from somedatabase



"RhysPieces" wrote:

I use several MS Queries to import into Excel '03 workbooks via ODBC from our
corporate mainframe (linked Access tables). I would like to rename the column
headings in the query design before returning the results to Excel. However,
despite the options to do so, I keep getting error messages about a 'missing
expected lexical'. I even tried editing the SQL statement but got the same
results. What's the trick to make MS Query rename the columns?



All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com