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 |
|
bendertez
Yak Posting Veteran
94 Posts |
Posted - 2008-07-02 : 10:26:43
|
| HelloI have a field that holds a person's course record called COURSE in a table called PERSON.People can be studying more than one course at a time so entries in the table can look like this (with PID being the person id and ref being the person's initials):PID- REF- COURSE123- DC-- Comm Skills123- DC-- IT Skills123- DC-- First Aid123- DC-- Health&Safety344- GD-- IT Skills344- GD-- First Aid225- SW-- Health&SafetyWhat I need to do is create a data extraction file to be imported in to another system but have to get the COURSE data out in to individual fields. i.e.for the person (PID) 123 i need to take their course data and seperate it in to the 4 diferent courses and enter the values in to 4 seperate fields:Field1------------Field2----------Field3---------Field4-------Comm Skills------IT Skills---------First Aid------Health&Safety Can this be achieved?Thank you |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-02 : 10:43:18
|
use the PIVOT operator KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
bendertez
Yak Posting Veteran
94 Posts |
Posted - 2008-07-02 : 10:52:33
|
quote: Originally posted by khtan use the PIVOT operator KH[spoiler]Time is always against us[/spoiler]
Does the PIVOT operator not work the other way around though?Where it will get data in the format of my required output fields and turn then in to a structure something that I started with?Can I reverse a pivot or specify a format?Thanks |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|