SQL Server Developer Center >
SQL Server Forums
>
SQL Server XML
>
Creating XMl out of relational tables with deep hierarchy
Creating XMl out of relational tables with deep hierarchy
- New to SQL Serer 2005.
I have an XSD out of which I created a database using open source utility. Now the tables generated are bit redundant, so some tables have been consolidated. The tables have a relational integrity and the hierarchy is bit deep.
My task is to create an XML out of the tables. Now If I pass the parent record id to the SQL server, What I would like to have is the whole tree under the parent record. Ideally this should match the XSD I originally used to create the tables in the first place.
My plan is to use VB.net with minimal coding on the client side. please let me know.
Answers
- I have used nested select for xml statements to return an xml document that conforms to the desired schema.
For more information about specifying both attribute-centric and element-centric XML with nested FOR XML queries, see FOR XML Query Compared to Nested FOR XML Query and Shaping XML with Nested FOR XML Queries .
/bac- Proposed As Answer bybobchauvin Tuesday, October 20, 2009 6:25 PM
- Marked As Answer byJian KangMSFT, ModeratorFriday, October 23, 2009 9:06 AM
- Hope this article will help you: http://xml.sys-con.com/node/46178
--------------
StarWind Software developer ( http://www.starwindsoftware.com )- Marked As Answer byJian KangMSFT, ModeratorFriday, October 23, 2009 9:06 AM
- Proposed As Answer byPaul Svirin Tuesday, October 20, 2009 4:16 PM
All Replies
- can you show us the sample of your xsd so we can see the structure.
Best Regards,
Melissa Suciadi
If you have found this post helpful, please click the 'Vote as Helpful' link (the green triangle and number on the top-left).If this post answers your question, click the 'Mark As Answered' link below. It helps others who experience the same issue in future to find the solution.
- I have used nested select for xml statements to return an xml document that conforms to the desired schema.
For more information about specifying both attribute-centric and element-centric XML with nested FOR XML queries, see FOR XML Query Compared to Nested FOR XML Query and Shaping XML with Nested FOR XML Queries .
/bac- Proposed As Answer bybobchauvin Tuesday, October 20, 2009 6:25 PM
- Marked As Answer byJian KangMSFT, ModeratorFriday, October 23, 2009 9:06 AM
- Hope this article will help you: http://xml.sys-con.com/node/46178
--------------
StarWind Software developer ( http://www.starwindsoftware.com )- Marked As Answer byJian KangMSFT, ModeratorFriday, October 23, 2009 9:06 AM
- Proposed As Answer byPaul Svirin Tuesday, October 20, 2009 4:16 PM


