Avatar of Larry Brister
Larry Brister
Flag for United States of America asked on

XML Select "TYPE=" or Version=""

How can I take my code below and when there's no OrganizationalType  return this

<OrganizationalType  Type="NOType"/>

Instead of this
<OrganizationalType />
Select blah...blah...blah...,
debtOrganizationalType 'Debtors/Names/IndividualName/OrganizationalType'  
from  
   research.dbo.r_data_ucc where debtLastName Like 'B%'  
for xml path('Record'

Open in new window

Microsoft SQL Server 2005Microsoft SQL Server 2008Microsoft SQL Server

Avatar of undefined
Last Comment
Larry Brister

8/22/2022 - Mon
derekkromm

Select blah...blah...blah...,
isnull(debtOrganizationalType, 'NOType') 'Debtors/Names/IndividualName/OrganizationalType'  
from  
   research.dbo.r_data_ucc where debtLastName Like 'B%'  
for xml path('Record'
Larry Brister

ASKER
derekkromm
That returns
<OrganizationalType>NOType</OrganizationalType>

I need
<OrganizationalType  Type="NOType"/>

ASKER CERTIFIED SOLUTION
derekkromm

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Larry Brister

ASKER
YEAH!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck