Software Engineer, Equity Strategist, Polymath.
Single Field to Multiple Rows
You want your field from all in one field
(No column name)
———————–
Mike,Joe,Jerry,Ben
to become separate rows like below?
NAME
——–
Mike
Joe
Jerry
Ben
then use script below..
declare @toRowXML xml SET @toRowXML = '<b><x>'+replace('Mike,Joe,Jerry,Ben',',','</x><x>')+'</x></b>' SELECT @toRowXML SELECT rtrim(ltrim(toRow.value('.','nvarchar(100)'))) as NAME from @toRowXML.nodes('/b/x') as t(toRow)
Leave a Reply
You must be logged in to post a comment.