Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 ) dfor xml path('BrokerID')select v as 'Value'from ( select 'MSCO' v ) dfor xml path('BrokerID')
Nathan Skerl
avmreddy17
Posting Yak Master
180 Posts
Posted - 2008-08-19 : 22:05:09
Anyway in SS 2000
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 ) BrokerIDfor xml auto
From BOL:
RAWThe 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
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
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