soozh
asked on
TSQL Select xml null values
MS SQL Server 2012.
I am using the following select statement to return an XML document:
However it does not return columns when the column value is null.
I have see that i can use ELEMENTS XSINIL to include null values but then i get the syntax:
Is there any way just to get an empty tag for null values:
I am using the following select statement to return an XML document:
set @xmlData =
( select(
select
[Id] as 'Id',
[RegisteringUnitId],
.....
[TumorhojdVetEj],
....
[UpdateUserId]
from OriginalData where Id = @id
for xml path ('OriginalData2012'), type)
for xml path('BAUM-registret'), type);
However it does not return columns when the column value is null.
I have see that i can use ELEMENTS XSINIL to include null values but then i get the syntax:
<TumorhojdVetEj xsi:nil="true"/>
Is there any way just to get an empty tag for null values:
<TumorhojdVetEj></TumorhojdVetEj>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Consider Example #C on the following page..
http://technet.microsoft.com/en-us/library/ms184325.aspx
HTH,
Kent