Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Converti il ​​valore della colonna Separato da virgole in righe

prova questo

 SELECT A.[id],  
     Split.a.value('.', 'VARCHAR(100)') AS String  
 FROM  (SELECT [id],  
         CAST ('<M>' + REPLACE([string], ',', '</M><M>') + '</M>' AS XML) AS String  
     FROM  TableA) AS A CROSS APPLY String.nodes ('/M') AS Split(a); 

fare riferimento qui

http://www.sqljason.com/2010/05/converting-single-comma-separated-row.html