/* So far, we have seen how to assign a custom name to the element as well as a custom name to each row. it is also possible to give a custom name to each element by using a column alias. The following example shows that. */ SELECT OrderNumber as 'OrderNum', ItemNumber as ItemCode, Qty as Quantity FROM OrderDetails FOR XML AUTO, TYPE, ELEMENTS, ROOT('itemInfo') /* OUTPUT: 00001 A001 10 00001 A002 20 00001 A003 30 */