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.