Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 creating XML from SQL table

Author  Topic 

shpinoza1980
Starting Member

17 Posts

Posted - 2010-10-18 : 05:10:56
Hi, I'm trying to create an xml document out of a sql 2005 table

I use this code in a query:

select p.name as "NAME"
from nop_product p
for xml path('PRODUCT'),ROOT('STORE')

my problem is that i need 3 level tree - all <PRODUCT> elements to be under <PRODUCTS> like this:
<STORE>
<PRODUCTS>
<PRODUCT>
<NAME> ..... </NAME>
</PRODUCT>
<PRODUCT>
<NAME> ....... </NAME>
</PRODUCT>
</PRODUCTS>
</STORE>

how do i do that? how do I add another permanent element after the ROOT tag and before the <PRODUCT> tag?
thanks
quote:

quote:

quote:

quote:



thanks a lot

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-19 : 13:39:10
howzz data present in your table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -