I have this code and I can't figure out how to get the expected result?
declare @table table (TAG int, PARENT int,col1 varchar(100)
,col2 varchar(100)
,col3 varchar(100))
insert into @table select 1, NULL, 'Value1'
, 'Value2'
, 'Value3'
select TAG,PARENT, col1 as [MyElement!1!!element],
col2 as [MyElement!1!!element],
col3 as [MyElement!1!!element] from @table for xml explicit
result :
<MyElement>Value1Value2Value3</MyElement>
expected :
<MyElement>Value1</MyElement>
<MyElement>Value2</MyElement>
<MyElement>Value3</MyElement>