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 - 2001-12-11 : 09:42:09
|
| Tim Pilkington writes "This is the only thing I could find on this problemSelect CODE,TITLE,Version,Status,Case @Price When 'Price' THEN Price When 'PriceA' Then PriceA When 'PriceB' Then PriceB When 'PriceC' Then PriceCEnd, Lots, LotsOf, Description,....Is there a way of doing away with the case statement as all it does is translate the @Price variable into a column name and the column name is the same as the string held in @Price?What I need is something likeSelect ColA, ColB, (@variable), ColD....Is this possible and if so how?(SQL Server 7)Thanks a lot." |
|
|
squisher
Starting Member
6 Posts |
Posted - 2001-12-11 : 10:13:56
|
| Something like this might work.SELECT @SQLSTATEMENT = ('SELECT ' + @Price + ' FROM myTable')EXECUTE sp_executesql @SQLSTATEMENT-Stefan- |
 |
|
|
|
|
|