SQL Server is having a fantastic feature to retrieve data persisted in the form of XML format. The data in the XML format can be retrieved using FOR XML clause appending to the SELECT statement.
It offers 3 modes.
- “FOR XML AUTO": Returns XML elements that are nested, based on which tables are listed in the "from" part of the query, and which fields are listed in the "select" part.
- "FOR XML RAW": Returns XML elements with the "row" prefix (ex: ""). Each column in a table is represented as an attribute and null column values aren't included.
- "FOR XML EXPLICIT": Explicit mode is the most complex shaping method used in SQL Server 2000. It allows users to query a data source in such a way that the names and values of the returned XML are specified before the query batch is executed.