Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When I trying to fetch data from sql server in XML format, all the null value fields is removed from out put .

What I have tried:

When I trying to fetch data from sql server in XML format, all the null value fields is removed from out put .
Posted
Updated 6-Aug-20 23:14pm

1 solution

This default behavior can be overridden by using the ELEMENTS XSINIL keyword phrase.

Similar to this: Columns that Contain a Null Value By Default - SQL Server | Microsoft Docs[^]
SQL
SELECT EmployeeID as "@EmpID",   
       FirstName  as "EmpName/First",   
       MiddleName as "EmpName/Middle",   
       LastName   as "EmpName/Last"  
FROM   HumanResources.Employee E, Person.Contact C  
WHERE  E.EmployeeID = C.ContactID  
  AND  E.EmployeeID=1
FOR XML PATH, ELEMENTS XSINIL;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900