Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 XML OUTPUT

Author  Topic 

avmreddy17
Posting Yak Master

180 Posts

Posted - 2008-08-19 : 18:22:13
Can we get this XML OUTPUT like <BrokerID value="MSCO" />
instead of <BrokerID>MSCO</BrokerID>
Thx

nathans
Aged Yak Warrior

938 Posts

Posted - 2008-08-19 : 22:02:47
In 2005 you can map to elements by using @ designator:


select v as '@Value'
from ( select 'MSCO' v
) d
for xml path('BrokerID')


select v as 'Value'
from ( select 'MSCO' v
) d
for xml path('BrokerID')



Nathan Skerl
Go to Top of Page

avmreddy17
Posting Yak Master

180 Posts

Posted - 2008-08-19 : 22:05:09
Anyway in SS 2000
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2008-08-19 : 22:10:00
I believe you can get same function by aliasing your table and column names:


select Value as 'Value'
from ( select 'MSCO' Value
) BrokerID
for xml auto


From BOL:

RAW
The RAW mode takes the query result and transforms each row in the result set into an XML element with a generic identifier row as the element tag and the columns in the SELECT as attributes.


Nathan Skerl
Go to Top of Page

avmreddy17
Posting Yak Master

180 Posts

Posted - 2008-08-19 : 22:11:03
Thanks Nathan. I really appreciate your help.
I will try it out

Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2008-08-19 : 22:13:21
No stress. Please post back if you run into any difficulty.

Nathan Skerl
Go to Top of Page
   

- Advertisement -