SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Advanced XML Processing


Advanced XML Processing

Author
Message
Adrian Hains
Adrian Hains
Old Hand
Old Hand (316 reputation)Old Hand (316 reputation)Old Hand (316 reputation)Old Hand (316 reputation)Old Hand (316 reputation)Old Hand (316 reputation)Old Hand (316 reputation)Old Hand (316 reputation)

Group: General Forum Members
Points: 316 Visits: 261
You can just cast the nvarchar column to xml, but this obviously incurs the overhead of parsing the content and would error out if the column contains invalid xml.

use tempdb;
create table t (i int, x nvarchar(100));
insert t values (1, '<abc>def</abc>');
go
select i, cast(x as xml) from t for xml auto
go
jacob sebastian
jacob sebastian
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2590 Visits: 2523

Do you have an example that shows your specific problem? I will try to help you out then.



.
stevemc
stevemc
SSC Veteran
SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)

Group: General Forum Members
Points: 223 Visits: 684

Very concise article. I spent a couple days figuring this out. Why is there nothing in BOL as simple as this?

You might note that to assign the results of the xml-generating query to a variable declared as XML, you need to surround the query in parentheses.

declare @xmlparm xml

select @xmlparm = (select orderid from order for xml auto, type)


Ivan Weaver
Ivan Weaver
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 Visits: 50

OH MY GIDDY AUNT!!!

This article is HUGE!!

Resultset > .NET Serialization > direct Object usage

You can autopopulate an objects list properties with a deserializing use of the resultset.

Have a CurrentOrder object? Derialize the resultset in to it. I realize I make it sound simple, but if you are creating a system or can fit in some design tweaks/adjustments to the system, then the ability to autopopulate an Order object directly from a result set without need to 'read' the result and load the properies manually? THAT'S HUGE !!


Suman Punukollu
Suman Punukollu
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 7
nice and simple
norman harley
norman harley
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 1
thanks for a well balanced document that gives concise information and syntax to a required information subject
Krupali Mehta
Krupali Mehta
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 5

Its very straightforward. also very practicle.

keep it up......!!!

thanks


d_george
d_george
SSC-Addicted
SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)SSC-Addicted (452 reputation)

Group: General Forum Members
Points: 452 Visits: 315

That's great. It helped me out a lot.

Does anyone have any info/styles/code/opinions on how to retrieve on the other end?

Specifically how to parse this file into variables in VB.Net?





Paul Manzano
Paul Manzano
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 11
Excellent Job! Very easy to follow!
flurk118
flurk118
Old Hand
Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)

Group: General Forum Members
Points: 307 Visits: 222
Nice article.

Has anyone got any examples of similar XML output but with header information included.

Following on from Jacobs article and presuming the existence of an OrderHeader table, the output would look something like attached


Ta
Attachments
order.txt (42 views, 499 bytes)
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