Fox XML in TSQL


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. 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.
  2. SQL
  3.  
  4. USE AdventureWorks2008R2;
  5. GO
  6. SELECT p.BusinessEntityID, FirstName, LastName, PhoneNumber AS Phone
  7. FROM Person.Person AS p
  8. JOIN Person.PersonPhone AS pph ON p.BusinessEntityID = pph.BusinessEntityID
  9. WHERE LastName LIKE 'G%'
  10. ORDER BY LastName, FirstName
  11. FOR XML AUTO, TYPE, XMLSCHEMA, ELEMENTS XSINIL;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.