0

I want to convert a comma seperated string list into different columns. Eaxh time the number of columns( items in the list) will be different . SO need to do this dynamically.
Example.
(1,2,3,4)
(1,2)
(1,2,3)
Conver first row into 4 columns, second into 2 and third into 3 columns.

I have these values in rows in one table I am using XML code to make it in string. Here is my code to convert rows into string

select barcode, stuff((SELECT ', ' + glce_score FROM #GLCE_Scores c1 where(c1.barcode = c.barcode) order by barcode,Strand_Sort,glce_sort FOR XML PATH('')),1,1,'') as name into #temp1 FROM #GLCE_Scores c group by barcode order by barcode
Now I have to convert that string into columns. In short I have to convert rows into columns.

TD2013
  • 97
  • 1
  • 3
  • 13
  • Sorry for the invalid and unnecessary rollback, I'm apparently illiterate today. That said, you need to show what you've tried so far. – LittleBobbyTables - Au Revoir Jun 12 '14 at 18:06
  • You would need to write your own function to do that - http://stackoverflow.com/questions/4200125/t-sql-convert-one-column-containining-delimiter-to-many-columns – TMNT2014 Jun 12 '14 at 18:11
  • I have update my question http://stackoverflow.com/users/334849/littlebobbytables – TD2013 Jun 12 '14 at 18:22

0 Answers0