Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

xml path help required

$
0
0

I have query - I'm sorry, i have not specified exact tables / field names. I just want to how do I get my required out put.

select empid, ename, cast ('<eventdata>' + '<dataitem>' + '<name> test </name>' + '<value> deptname </value>'  + '</dataitem>'
+ '</eventdata>' as varchar(max) )as data_xml from table1
inner join table inner join table3
deptname is field in table1
when I run above query, am getting below output

output -

empid,ename,data_xml

1, dinesh, <eventdata><dataitem><name>test</name><value>a</value></dataitem></eventdata>
1, dinesh, <eventdata><dataitem><name>test</name><value>b</value></dataitem></eventdata>
but if you notice, all values are same except a, b in xml section

so, i want to have only 1 row like this...

empid,ename,data_xml

1, dinesh, <eventdata><dataitem><name>test</name><value>a,b</value></dataitem></eventdata>

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>