Dynamic header in select statement

Posted by Murugavelmsc under Sql Server on 10/1/2014 | Points: 10 | Views : 412 | Status : [Member] | Replies : 0
Hi Experts,

I have written a sql query with multiple tables.

In this I have defined the dynamic header,
ie.

Select
ID,
Name,
[Calender Year YYYY] = some value
[Calender Year YYYY] = some value
[Calender Year YYYY] = some value

from
multiple tables (joins)

Run the query in current years means,

header as
[Calender Year 2013] = some value
[Calender Year 2012] = some value
[Calender Year 2012] = some value

I have tried

declare @sql varchar(max) = "sql stmts"
exec(@sql)

It works fine,

Any other solution.

Thanks,
Murugavel S

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/



Responses

(No response found.)

Login to post response