Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Queries: Rename columns

Status
Not open for further replies.

mattsv

Programmer
May 21, 2005
28
US
Hello,

When I use the keyword "AS" to rename a column in a SQL query, it does not rename the column in the table returned by the query:

SELECT Customer.ID, Customer.Address AS CustomerAddress

The table that is returned has "Address" instead of "CustomerAddress" as the name of the attribute.

I've read postings on this where users said to ALTER a table. Is this a shortcoming in Access or is this intentional? I use Access 2002.

How would you recommend doing this?
 
Try:
SELECT Customer.ID, Customer.Address AS [CustomerAddress]

Access likes seeing the square brackets around the names. I've used other programs' SQL that treat anything in quotes as a column name.
 
From a grammer perspective, what function do the brackets pose in this instance? Why isn't just using the "AS" keyword enough?
 
mattsv
The sqaure brackets are used to qualify the name of field or parameter. Square brackets are not always required for field names. When writing SQL Access will automaticaly put the square brackets when the field name has no spaces.

The quotes are used to qualify text strings. There are times when the name of the field or control is the text string and will need to be quoted.

Check your help file on referencing field name or control names.
 
check your 'Caption' property for that field in his parent table, as query uses that if has been set

greets,
Marko 9A6NCM

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top