Hi
I am trying to assign a column name based on input parameter, is this at all possible? I.e.
declare @monthName varchar(10)
set @monthName = 'January'
select datepart(day, timestamp) as 'Day', count(*) as 'Books sold in ' + @monthName
from sales
I want the second column's name to be [Books sold in January]. I know that I could do this:
declare @monthName varchar(10)
set @monthName = 'January'
declare @query varchar(8000)
select @query =
' select datepart(day, timestamp) as [Day], count(*) as [Books sold in ' + @monthName + ']
from sales'
exec (@query)
Reason for trying to do the first method is that I need to define the column names in the query - when displayed, I cannot do any manipulation, WYSIWYG system.
Thanks!
Cobus