473,387 Members | 1,628 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do i add attributes in sql for xml

1
(select
'99999' as [ram:ID],
/* the rest of the codes */


out put :
<ram:ID> 99999 </ram:ID>

but what i need is :

<ram:ID schemeAgencyID="1"> 99999 </ram:ID>
Jun 9 '14 #1
1 1396
Luuk
1,047 Expert 1GB
after looking at this
something like:

Expand|Select|Wrap|Line Numbers
  1. select 1 as Tag, null as Parent, 
  2.     FromDate as [PHD!1!test],
  3.     null as [FT!2!FromDate!ELEMENT], 
  4.     null as [FT!2!ToDate!ELEMENT]
  5. from PHD
  6. union all
  7. select 2 as Tag, 1 as Parent, '',
  8.     FromDate, 
  9.     ToDate
  10. from PHD
  11.  for xml EXPLICIT
results in:
Expand|Select|Wrap|Line Numbers
  1. <PHD test="2014-04-15T10:00:00" />
  2. <PHD test="2014-04-25T10:00:00" />
  3. <PHD test="2014-05-16T10:00:00" />
  4. <PHD test="2014-05-18T10:00:00">
  5.   <FT>
  6.     <FromDate>2014-04-15T10:00:00</FromDate>
  7.     <ToDate>2014-06-01T12:00:00</ToDate>
  8.   </FT>
  9.   <FT>
  10.     <FromDate>2014-04-25T10:00:00</FromDate>
  11.     <ToDate>2014-05-21T12:00:00</ToDate>
  12.   </FT>
  13.   <FT>
  14.     <FromDate>2014-05-16T10:00:00</FromDate>
  15.     <ToDate>2014-05-16T12:00:00</ToDate>
  16.   </FT>
  17.   <FT>
  18.     <FromDate>2014-05-18T10:00:00</FromDate>
  19.     <ToDate>2014-05-31T18:00:00</ToDate>
  20.   </FT>
  21. </PHD>
i dont know how to get rid of the extra 'empty' PDH tags, but this example could be helpfull (in combination with the link)
Jun 9 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

50
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
9
by: Soren Kuula | last post by:
Hi, I just can't find namespaces of attributes stated clearly enough in the XML namespace spec. But .. I hear rumors that attributes, unless qualified otherwise, default to the namespace of the...
7
by: Info 3000 | last post by:
Hello, I'm beginner in XML. I have just a little question : I understand that I can write : <Book> <Title> A nice day </Title> <Author> James Nicepen </Author> </Book>
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
7
by: localhost | last post by:
What is the best and/or fastest way to enumerate attributes of an HTML control? In my page template, I have: <body id="myBody" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"...
3
by: Janaka | last post by:
I've seen and used some samples where you can set the onclick attrubute to a Button control to get it to do some javascript a la : btnUse.Attributes = "DoSomeJS()"; However when i try and get...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
2
by: james_027 | last post by:
hi everyone, I am now in chapter 5 of Dive Into Python and I have some question about it. From what I understand in the book is you define class attributes & data attributes like this in python...
2
by: cloftis | last post by:
Using VS2003, VB and MSHTML, Using an HTMLSpanElement I want to enumerate the attributes of a SPAN tag. 1 'For testing sake 2 Dim strMarkup as String = "<span attr1='somevalue'...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.