Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to cancatenate a field name with a perameter

Author  Topic 

dmlJun2009
Starting Member

4 Posts

Posted - 2009-07-13 : 18:58:27
Hello all,
I'm trying to cancatenate a field name with a perameter,

Example:
declare @EndDate as datetime
set @EndDate = '12/31/08'
select
[ItemNo] as '[Unit Cost Old '+@EndDate+']'

So the ending name of the field becomes [Unit Cost Old 12/31/08]
Any idea on how this can be done?

Thanks,

dmlJun2009

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-07-13 : 19:26:27
Don't do this in T-SQL, do this in your application.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

dmlJun2009
Starting Member

4 Posts

Posted - 2009-07-13 : 19:34:48
I'm trying to output the table into an excel spreadsheet without having to change the header names. Any reason why I should not be doing it in T-SQL?

Thanks,


dmlJun2009
Go to Top of Page
   

- Advertisement -