T-SQL XML Closing Tag On Empty Elements -


i trying write query returns xml using t-sql. when run query not have sibling elements closing tags left , not converted self closing tags.

create table #seg (     householdexternalid int,     id int )  insert #seg select 2534640, 265 union select 2534644, 265 union select 2534650, 265 union select 2534661, 265 union select 2534669, 265 union select 2534684, 265 union select 2534689, 265 union select 2534692, 265 union select 2534694, 265 union select 2534698, 265  select     1 'id',     (         select              householdexternalid 'householdexternalid',             (                 select null 'blank',                 (                     select  id 'id', 1 'status',                     (                         select  '' xml path (''), type                     )                        #seg aa                       aa.householdexternalid = a.householdexternalid                      xml raw ('segment'), type                 )                 xml raw ('householdsegments'), type             )             #seg             xml raw ('household'), type     )     xml raw ('retailer'), type 

a snippet resulting xml shows full closing tag.

<segment id="265" status="1"></segment> 

when try adjust query return result sibling elements, closing tags changed self closing. how can full closing stay?

select     1 'id',     (         select              householdexternalid 'householdexternalid',             (                 select null 'blank',                 (                     select  id 'id', 1 'status',                     (                         select  '' xml path (''), type                     )                        #seg aa                       aa.householdexternalid = a.householdexternalid                      xml raw ('segment'), type                 )                 xml raw ('householdsegments'), type             )             #seg             xml raw ('household'), type     ),     (         select              householdexternalid 'householdexternalid',             (                 select null 'blank',                 (                     select  id 'id', 1 'status',                     (                         select  '' xml path (''), type                     )                        #seg aa                       aa.householdexternalid = a.householdexternalid                      xml raw ('segment'), type                 )                 xml raw ('householdsegments'), type             )             #seg             xml raw ('household'), type     )      xml raw ('retailer'), type 

a snippet resulting xml shows self closing tag not want.

<segment id="265" status="1" /> 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -