I have a requirement of exporting my data into a XML format. For simplicity, consider that I have a table Employee with FName,MName and LName columns. To export the data into XML, I have written the following query
SELECT FName, MName, LName from Employee FOR XML PATH ('Emp Details'), ROOT ('Details');
This return the data in correct XML format. However, if there is any row with NULL value, it skips the XML tag for that column. Like in following example MName had a NULL value therefore the tag for MName was missing in the XML as well:-
<Emp Details>
<Details>
<FName>Rohit</Fname>
<LName>Kumar</LName>
</Details>
</Emp Details>
I have tried using ELEMENTS XSINIL method but it displays the tag like
<MName xsi:nil="true" />
however, I want it to be displayed as
<MName />
Is it possible to display the NULL value XML tags in such a manner?
Thanks
''instead, that'll force the node to be displayed. SoISNULL(MName,'')would force the node to appear, but blank.