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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-10-02 : 07:56:20
|
| NAndu writes "Hello sir, I want some help...set @var='[Channel ' + Convert (nvarchar(2),sum(@aint)) + ']'select @Channel = @var from database1 where [station Address] = '1'I want @var should be considered as column name.And value of yhat column is set to the @channel variable..." |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-10-02 : 08:20:34
|
| http://www.sommarskog.se/dynamic_sql.htmlChirag |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-02 : 09:09:15
|
| SELECT SUM(CASE @ChannelWHEN 1 THEN [Channel 1] WHEN 2 THEN [Channel 2]WHEN 3 THEN [Channel 3]WHEN 4 THEN [Channel 4]END)FROM Database1WHERE [Station Address] = '1'Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-02 : 09:27:41
|
| Why do you use Dynamic SQL?If you are trying Cross tab, then read about Cross-tab Reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|