Wednesday, December 31, 2014

I need to concatenate xml string and output shoul be in table using t-sql


DECLARE @x xml =
'<bo>
<ID>1</ID>
<DetailList>
<Detail>abc</Detail>
<Detail>def</Detail>
</DetailList>
</bo>
<bo>
<ID>2</ID>
<DetailList>
<Detail>bcd</Detail>
</DetailList>
</bo>'
SELECT t.u.value('ID[1]','int') AS ID,
t.u.query('data(DetailList/Detail)').value('.','varchar(max)') AS DetailList
FROM @x.nodes('/bo')t(u)





Please Mark This As Answer if it solved your issue

Please Vote This As Helpful if it helps to solve your issue

Visakh

----------------------------

My Wiki User Page

My MSDN Page

My Personal Blog

My Facebook Page


No comments:

Post a Comment