sql >> Base de Datos >  >> RDS >> Sqlserver

Convierta el valor de la columna separada por comas en filas

prueba esto

 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); 

consulte aquí

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