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
 General SQL Server Forums
 New to SQL Server Programming
 rows to columns

Author  Topic 

joanne
Starting Member

46 Posts

Posted - 2010-12-06 : 17:50:24
Hello,
I have a table with 2 columns:

No SerialNumber
123 4GB6Y78
123 53F7TH
124 4GB6Y78
124 53F7TH
124 53E8BX
the question is :
how to get the results as following:

123 4GB6Y78 53F7TH
124 4GB6Y78 53F7TH 53E8BX
...
125 with 6 columns....
etc...

Thank you very much!

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-12-06 : 22:41:53
I have a blog article to maybe assist you with your question:,

http://www.sql-programmers.com/Blog/tabid/153/EntryId/6/Using-PIVOT-and-UNPIVOT.aspx

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-07 : 02:16:08
For unknown number of values, use dynamic pivot
http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -