What is the use of FOR XML in SQL Server?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.
There are 3 modes:
1. “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. 2. "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. 3. "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.
|