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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Row to Column Conversion

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-12 : 11:10:10
Mike writes "How can I take unique pieces of information from a row and convert it to a column. I would like to create a flat file out of a STUDENT table that has the student name for each course they are registered in. The current table resembles this:

Name, Course
john doe, math2222
john doe, psy1300
bill scott, eng4444
anne frank, musi5432
anne frank, poli2343

I would like to query this this data to create the following output. Notice that the Courses field has multiple pieces of information separted by colon. If this is not possible could I create a query that would create a new column for the highest number of courses one student may be in and populate it with the unique courses?

Name, Courses
john doe, math2222:psy1300
bill scott, eng4444
anne frank, musi5432:poli2343"
   

- Advertisement -