we have a simple table and need convert to XML
Declare @Person TABLE
( [BusinessEntityID] [int] NOT NULL,
[PersonType] [varchar](2) NULL,
[Title] [varchar](30) NULL,
[FirstName] [varchar](30) NULL,
[MiddleName] [varchar](30) NULL,
[LastName] [varchar](30) NULL)
Insert Into @Person Values(10001,'IN','Article','Carolyn','Jo','Alonso')
we need this xml for output with For XML in sql server
<?xml-stylesheet type='text/xsl' href='result.xsl'?>
<documents>
<document>
<field name="BusinessEntityID">10001</field>
<field name="PersonType">IN</field>
<field name="Title">Article</field>
<field name="FirstName">Carolyn</field>
<field name="MiddleName">Jo</field>
<field name="LastName">Alonso</field>
</document>
</documents>