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 |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2005-08-23 : 11:51:23
|
| How can I covert row to column?Population moderate High100 60 40toPopulation 100moderate 60High 40 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2005-08-23 : 15:01:19
|
| [code]SELECT 'population' AS MyColumn1, mt.population AS MyColumn2FROM dbo.MyTable AS mtUNION SELECT 'moderate', mt.moderateFROM dbo.MyTable AS mtUNION SELECT 'high', mt.highFROM dbo.MyTable AS mt[/code]If you want to do this dynamically, you'll need to construct the SQL using metadata (information_schema.columns).Mark |
 |
|
|
|
|
|