sql - splitting a single row into multi rows -
possible duplicate:
query display row data column
hi have single row holding data 1,2,10,4,5,6,7,8,13,16,17,3. need query split them sequence row. such 1 should appear in 1st row, 2 in second row, 10 in third row................
use replace make comma separated string xml. can use cross apply nodes() of xml rows , use value() function node value.
declare @str varchar(100) = '1,2,10,4,5,6,7,8,13,16,17,3' select r.value('.', 'int') val (select cast('<r>'+replace(@str, ',', '</r><r>')+'</r>' xml)) x(x) cross apply x.nodes('r') r(r) if need use table instead of variable can have here. how split repeating string delimated commas in t-sql
Comments
Post a Comment