Avatar of soozh
soozhFlag 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
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Hi,

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

Giannis
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
Avatar of soozh
soozh
Flag of Sweden image

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.
ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of soozh
soozh
Flag of Sweden image

ASKER

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

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.

61K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo