Avatar of soozh
soozh
Flag for Sweden asked on

TSQL - working with XML.

Hello,

I am writing a stored procedure that will return an xml document.  

The document contains 3 sections.  

I am thinking that i would first create the three different sections with their own TSQL and then combine them into the final xml document.

Is this OK?  And if so how would i modify my xml document to insert the three sections between the root tags?

Using SQL Server 2008.

/Thanks
XMLMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
soozh

8/22/2022 - Mon
Ioannis Paraskevopoulos

Hi,

Can you post a sample table with data and the expected XML format?

Giannis
Deepak Lakkad

Hi,

you can use FOR XML clause to generate XML

following link will be helpful for that

http://msdn.microsoft.com/en-us/library/ms178107.aspx

- Deepak Lakkad
soozh

ASKER
Thanks for the link but i have already done my homework and i can produce the xml i need.

My question is if it is bad practice to generate the seperate sections and then join them in one xml document.

And if this is possible how would i do:

xmlDoc = xmlSection1 + xmlSection2 + xmlSection3

I.e. is there syntax/tools to work with xml appart from select/insert etc.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Ioannis Paraskevopoulos

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
soozh

ASKER
Thanks Giannis... that is exactly what i need.