/* So far, we are able to format the XML results in the way we wish. We are able to rename the root node, rows and element names. Now let us look at a different case. When SQL Server generates the XML results, it will skip the columns which has NULL values. Let us look at an example. The code below, updates a column to NULL. Look at the results. The third row does not have element. */ UPDATE OrderDetails SET Qty = NULL WHERE OrderDetailID = 3 SELECT OrderNumber, ItemNumber, Qty FROM OrderDetails FOR XML RAW('itemInfo'), TYPE, ELEMENTS, ROOT('orderInfo') /* OUTPUT: 00001 A001 10 00001 A002 20 00001 A003 */