Alternate column name via SQL query

riggsd

Board Regular
Joined
Jan 29, 2003
Messages
143
How do I provide an alternate column header name in Access in a SQL Query?

I need to provide a column header with a more meaningful header title for management when extracting data from Access via query. I know there's a way to do it in the SQL query but for the life of me can't remember or find it (my google-fu is lacking today).

Thanks
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Re: a

Put

Code:
AS ColumnHeaderName

after the header name in the code. Change "ColumnHeaderName" to a name of your choice.
 
Last edited:
Upvote 0
Re: a

That's what I've been doing but it won't override the column header set as the Caption in the table design.
 
Upvote 0
Re: a

Are you writing a query? This works 100% of the time for me when I write queries.
 
Upvote 0
Re: a

Not for me with 2007. The table alias overrides a query field alias. It should be rare that a properly coined table field alias would not be good enough for a query. If you think about it, the field name should follow proper naming conventions, so we use an alias (caption) to provide a more descriptive term everywhere we need to see the field name. So why use an alias in a table that's not good enough for every query? I suppose there's an exception to every case. I think there's a work around that requires a module level function which you call from the SELECT portion of the sql statement. Can get messy and is just a weird (IMHO) alternative to having a globally acceptable alias.

If you consider that query results should be viewed in a form or report, then this is even less of an issue. The control label should take over regardless of form view AFAIK.
 
Upvote 0
Re: a

Select Field1 As Field2 From Table1.
The query results will show a column called Field2. I'm not understanding the problem.
 
Upvote 0
Re: a

Did you try this on a table field with a caption? That overrides the query alias as mentioned. Maybe it's version dependant.
 
Upvote 0
Re: a

I see. I don't usually use captions.

Ironically, it seems this thread has also gotten a new "caption" somehow. Well, that figures.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,710
Messages
6,161,445
Members
451,706
Latest member
SMB1982

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top