I needed to update the query below to work with my data. This is what i got:select ID, Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8, Column9into #tFrom #OriginalTableselect ID as IDTAG, p.[1],p.[2],p.[3],p.[4],p.[5], p.[6],p.[7],p.,p.[9] into #u from #tcross apply ( select colval , rn = ROW_NUMBER() over(order by colval) from (values (Column1), (Column2), (Column3), (Column4), (Column5), (Column6), (Column7), (Column8), (Column9)) r(colval)) rpivot (max(colval) for rn in ([1],[2],[3],[4],[5],[6],[7],,[9])) p
However,this works up until the data in the cell <= 9 as it sees the cells as string. For values >9 it doesn't work.How can I fix that?