I need to use result of a SQL query to set column aliases. Please see below script and the result of the script I need to use it as column aliases.
select
convert(varchar,DATEADD(month, -12, dateadd(d,-day(convert(date,dateadd(d,-(day(getdate())),getdate()))),convert(date,dateadd(d,+1-(day(getdate())),getdate())))),107),
convert(varchar,convert(date,dateadd(d,-day(convert(date,dateadd(d,-(day(getdate())),getdate()))),convert(date,dateadd(d,+1-(day(getdate())),getdate())))),107)
I need the answer for my question as soon as possible.
Two solutions are described in the following link: Column alias based on variable
First solution:
Execute the query using sp_executesql
Second solution: Rename the column after the execution of the query