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
+ '</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>
1, dinesh, <eventdata><dataitem><name>
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>