I have CSV data stored in a column in SQL Server 2008.
[PKID] [DataCSV]
1      1,2,4
2      3,5
The following will convert that data into rows...
; WITH [XmlTable] AS (
   SELECT [PKID], 
          CAST('<d><i>' + REPLACE([MyData],',','</i><i>') + '</i></d>' AS XML) AS [MyDataXml]
   FROM [MyTable]
)
SELECT [PKID],
  CX.value('.','int') AS [DataItem]
FROM [XmlTable]
  CROSS APPLY [MyDataXml].nodes('/d/i') AS CX(CX)
With the correct/expected/wanted result of...
[PKID] [DataItem]
1      1
1      2
1      4
2      3
2      5
My question is whether there is a better, more efficient, more accepted way of achieving the same thing without the use of CTE/XML?
