for xml - SQL Server 2008: How to remove namespace from the elements, but let it display on root -


i using sql server2008 xml clause generate xml file using bcp.

when use below query, result fine:

with xmlnamespaces (            'http://base.google.com/ns/1.0' g,    default 'http://www.w3.org/2005/atom'     ) select id, name "g:name" paymentmethods xml path ('entry'), root('feed')  

result:

<feed xmlns="http://www.w3.org/2005/atom" xmlns:g="http://base.google.com/ns/1.0">   <entry>     <id>1</id>     <g:name>bpay</g:name>   </entry>   <entry>     <id>2</id>     <g:name>cash</g:name>   </entry> </feed> 

but want add static elements, say, title , date after root. able that, then, namespace tags appear in element don't want. please note, want elements namespace prefix eg,

query using is:

with xmlnamespaces (     'http://base.google.com/ns/1.0' g,     default 'http://www.w3.org/2005/atom'     ) select  'google feed' title, convert(date, getdate()) updated, (    select id, name "g:name" paymentmethods xml path ('entry'), type )  xml path(''),   root('feed')  

and result is:

<feed xmlns="http://www.w3.org/2005/atom" xmlns:g="http://base.google.com/ns/1.0">   <title>google feed</title>   <updated>2012-06-27</updated>   <entry xmlns="http://www.w3.org/2005/atom" xmlns:g="http://base.google.com/ns/1.0">      <id>1</id>     <g:name>bpay</g:name>   </entry>  <entry xmlns="http://www.w3.org/2005/atom" xmlns:g="http://base.google.com/ns/1.0">     <id>2</id>     <g:name>cash</g:name>   </entry> </feed> 

whereas want result like:

<feed xmlns="http://www.w3.org/2005/atom" xmlns:g="http://base.google.com/ns/1.0">   <title>google feed</title>   <updated>2012-06-27</updated>   <entry>     <id>1</id>     <g:name>bpay</g:name>   </entry>   <entry>     <id>2</id>     <g:name>cash</g:name>   </entry> </feed> 

please help...

thanks,

ps


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -