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.
| Author |
Topic |
|
shaggy
Posting Yak Master
248 Posts |
Posted - 2011-11-02 : 07:21:34
|
| Hi,I want to get dynamic alias name.can anyone pleasehelp me out in this. declare @t nvarchar(max) ='select 1 as @t1',@t1 varchar(100) = 'number',@t2 nvarchar(max)set @t2 = '@t1 varchar(100)'exec sp_executesql @t,@t2,@t1= @t1 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-02 : 07:22:50
|
| why should alias be dynamic? can you specify need for this?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
shaggy
Posting Yak Master
248 Posts |
Posted - 2011-11-02 : 07:38:14
|
| In store procedure alias name comes as input parameter. I have to bind the alias name.The output of sp is comparison between two months.output :-col : total_sales jan feb 10 2 8 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-02 : 07:49:31
|
quote: Originally posted by shaggy In store procedure alias name comes as input parameter. I have to bind the alias name.The output of sp is comparison between two months.output :-col : total_sales jan feb 10 2 8
i certainly dont see a need for this. you can very well generate this columnname using date values in procedure or in front end------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-03 : 06:18:06
|
| Make sure you read this fullywww.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|