XML RAW :hver række i resultatsættet tages som ét element med dine kolonner som attributterne.
Eksempel:
USE BOB_DATABASE
SELECT ID, Name, First_Name, Last_Name
FROM DBO.T_User
FOR XML RAW;
OUTPUT:
<row id="7801020202083" First_Name="John" Surname="Doe" />
<row id="9812150201082" First_Name="Samantha" Surname="Hill" />
XML AUTO :Tabelnavne er dine elementer
Eksempel:
USE BOB_DATABASE
SELECT ID, Name, First_Name, Last_Name
FROM DBO.T_User
FOR XML AUTO;
OUTPUT:
<DBO.T_USER id="7801020202083" First_Name="John" Surname="Doe" />
<DBO.T_USER id="7801020202083" First_Name="John" Surname="Doe" />
XML-sti:Tabelkolonner sendes som underordnede elementer.
Eksempel:
USE BOB_DATABASE
SELECT ID, Name, First_Name, Last_Name
FROM DBO.T_User
FOR XML PATH;
OUTPUT:
<row>
<id>7801020202083</id>
<First_Name>John</First_Name>
<Surname>Doe</Surname>
</row>
<row>
<id>7801020202083</id>
<First_Name>John</First_Name>
<Surname>Doe</Surname>
</row>
Tjek også denne blog https://www.simple-talk.com/sql/learn-sql-server/using-the-for-xml-clause-to-return-query-results- as-xml/ for en bedre opdeling.