Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XML Select "TYPE=" or Version=""

Posted on 2011-03-04
4
Medium Priority
?
259 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:derekkromm
ID: 35038318
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'
0
 

Author Comment

by:lrbrister
ID: 35038364
derekkromm
That returns
<OrganizationalType>NOType</OrganizationalType>

I need
<OrganizationalType  Type="NOType"/>

0
 
LVL 15

Accepted Solution

by:
derekkromm earned 2000 total points
ID: 35038378
isnull(debtOrganizationalType, 'NOType') 'Debtors/Names/IndividualName/OrganizationalType/@Type'  
0
 

Author Closing Comment

by:lrbrister
ID: 35038449
YEAH!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question