Link to home
Start Free TrialLog in
Avatar of pstre
pstre

asked on

SQL statement help...

I am trying to rename the fields and cannot do it .. If I want to rename the following to Department Description, what syntax would I use.  I tried T1.[Segment1 Description] AS Department Description but got an error message.

T1.[Segment1 Description],
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you trying to return a different name from a select statement or rename the column in the database?
Shaun Kline's answer is correct.   T1.[Segment1 Description] AS [Department Description]

I'll add my .02 in that the only time I would intentionally alias a column with a space is if the object I'm writing is used as the data source for a report, where you want the column headers to be English-user-readable.   Even then I'd consider stating the English-user-readable column header in the report, and not in the SQL code.

Otherwise, the forcing of square brackets [ ] is one more thing to potentially forget and cause an error.
pstre - If you don't mind I'm going to unaccept the answer to allow for a regrade, specifically for a split between myself and Shaun Kline, as EE etiquette doesn't encourage an 'That guy's answer is correct' type comment to receive all points.

Thanks in advance.
Jim
Avatar of pstre
pstre

ASKER

Thank you... I was using spaces in the renaming of the column and that was the problem...