Assume I have the following, in T-SQL:
declare @.xml1 xml
declare @.xml2 xml
set @.xml1 = '<first></first>'
set @.xml2 = '<second></second>'
I want to combine these, into the following, and return the results typed as XML:
<results>
<first></first>
<second></second>
</results>
I can't seem to find any way to do this - other than converting them to a string, and concatinating them and then typing the results as XML. Any ideas?
Thanks,
Scott
One way to do this is to use 'FOR XML PATH'
declare @.xml1 xml
declare @.xml2 xml
set @.xml1 = '<first></first>'
set @.xml2 = '<second></second>'
select @.xml1 , @.xml2
FOR XML PATH ('results'), type
The section 'Constructing XML Using FOR XML ' in BOL has more information about the different FOR XML capabilities.
Thanks
Babu
|||Beautiful!!!
Thank you Babu!
No comments:
Post a Comment