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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can we create alias from concatenated columns?

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
Hi, Is it possible to create an alias from a concatenation of a column and a string or another column? For exmple:

Select ID + ' ' + FName as ID +'2008XYZ'
from employee;

Result: (say ID=1001)

10012008XYZ <--- column alias
1001 John <--value

I have trid but getting errors. I am using SQL Server 2005. Thanks in advanced.
 
I do not think this is possible. You would have as many columns as you have values, and i don't think SQL likes that.

I tried both the way you have it listed and various forms of:

SELECT [FName + '2008XYZ'] = ID + ' ' + FName FROM Employee

I just don't think it likes dynamic columns like that.

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
No you can't. This is typically done on the front end application or reporting tool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top