/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
The following example specifies FOR XML AUTO WITH the TYPE AND XMLSCHEMA options. Because OF the TYPE OPTION, the RESULT SET IS returned TO the client AS an xml TYPE. The XMLSCHEMA OPTION specifies that the inline XSD schema IS included IN the XML DATA returned, AND the ELEMENTS OPTION specifies that the XML RESULT IS element-centric. SQL USE AdventureWorks2008R2; GO SELECT p.BusinessEntityID, FirstName, LastName, PhoneNumber AS Phone FROM Person.Person AS p JOIN Person.PersonPhone AS pph ON p.BusinessEntityID = pph.BusinessEntityID WHERE LastName LIKE 'G%' ORDER BY LastName, FirstName FOR XML AUTO, TYPE, XMLSCHEMA, ELEMENTS XSINIL;