


We use this information to address the inquiry and respond to the question.

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including: Questions and Inquiriesįor inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. Please note that other Pearson websites and online products and services have their own separate privacy policies. This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site. If you want more control over your XML formatting than RAW or AUTO provide, use the EXPLICIT value. The Authors element is the parent element the elements inside it are thechild elements. The titles for each author are nownested as their own elements inside an Authors element. Listing 3 Query for AUTO Format Select _id,_lname,_fname,Titles.titleFrom Authors,Titleauthor,TitlesWHERE _id = _id And Titles.title_id = Titleauthor.title_idORDER BY _lname FOR XML AUTO Listing 4 XML Result Set in AUTO Format After running thesame query using the AUTO value as shown in Listing 3, we get theresults in Listing 4. Notice that each row is an element in RAW format. Listing 1 Query for RAW Format Select _id,_lname,_fname,Titles.titleFrom Authors,Titleauthor,TitlesWHERE _id = _id And Titles.title_id = Titleauthor.title_idORDER BY _lname FOR XML RAW Listing 2 XML Result Set in RAW Format Listing 1 shows the query and Listing 2 shows theXML result set returned using the RAW value. To compare the results, I used the Query Optimizer with the Pubs database andthe example just described. Using EXPLICIT, you can place data in certain sections of an XMLdocument, hide columns, force attributes to become elements, and more.AUTO would nest allthe titles returned in the Titles table as elements within a main Author element for each author returned by the Authorstable. Suppose we're doing aquery on three tables, getting the author's name and ID from the Authors table, and the titles tied to this author from the Titleauthor and Titles tables. AUTO nests elements inside other elements, making it easier toperform more advanced queries on the XML document.RAW is the least-nested format it's good for XML documents thatdon't need extensive data manipulation. RAW returns each row returned by the query as an XML element.When using the FOR XML clause, the MODE argument determines how the XML data is to be formatted in theresult set, by using one of three values: RAW, AUTO, or EXPLICIT. Simplystated, to have the most control over your data in an XML document for retrievalpurposes, you use nesting. If you're at all familiar with XML, you're probably aware of thehierarchical formatting arrangements of XML elements and attributes. Instead, to return data as XMLfrom a query, we'll use the Transact SQL (T-SQL) FOR XML clause,which can be used at the end of a SELECT statement. Because XML isa markup language like HTML, it would be tedious to have to convert the datamanually, especially with a very large recordset. We can use SQL Server to return results from a dataset as XML. Learn More Buy Returning Data as XML from the SQL Server Database
