Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


An Alternative XML Solution


An Alternative XML Solution

Author
Message
Wayne-153714
Wayne-153714
SSC-Enthusiastic
SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)SSC-Enthusiastic (146 reputation)

Group: General Forum Members
Points: 146 Visits: 91
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/WFillis


When in doubt - test, test, test!

Wayne

Hugh Lynch
Hugh Lynch
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 1

There are indeed many solutions to creating XML from SQL Server. I have had good success for several years using stored procedures that return multiple recordsets with embedded instructions for converting them to XML. The only non-SQL code required is a generic utility class that executes the stored procedures, then interprets and converts the results. For example:

create procedure shpClientOrders( @clientID int ) as
select 'DATASET clients.client' AS _shapeInfo
select * from clients where id=@clientID

select 'DATASET orders.order RELATE TO clients' as _shapeInfo
select * from orders where clientID=@clientID

select 'DATASET orderItems.item RELATE orderID to orders.id GROUPRECORDS' as _shapeInfo
select * from orderItems where clientID=@clientID


results in:

<client id='1234' name='Client Name'...>
<order id='92342' orderDate='2004-10-12'>
<items>
<item id='00093' description='Skippy 12oz.' quantity='3'/>
<item id='00093' description='Welch's 8oz.' quantity='2'/>
</items>
</order>
</client>





Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search