Advanced XML Processing

  • Comments posted here are about the content posted at


  • Excellent. Now we're cookin' with gas! Thanks.

  • Nicely done... simple and easy language.

    Keep it up!!!

  • I found article very usefull. Thank you.

  • great article! I never realised how simple it actually is to get XML out of 2005.

  • I agree, that was a great article.  Very simple and very worthwhile.

  • Very helpful, thanks. If you have xml already in an nvarchar column, is there any way to have it not be escaped in the for xml output? I'm thinking I might be able to write a query that would insert that nvarchar column into a temp table with an xml datatype. Then I would be able to query inside the xml document itself while joining with other data. Right now we are stuck with LIKE queries.

  • Very nicely-presented article - well done Jacob!

    My only suggestion would be to rename this particular article to 'Simple XML Processing', as some people might be unnecessarily scared off 

    I look forward to the next article...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • Thanks! I needed That

    Artificial Intelligence stands no chance against Natural Stupidity.

  • Great Article! Simple through examples and very clear.

    Keep'em comming


    * Noel

  • 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>');


    select i, cast(x as xml) from t for xml auto


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


  • 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)


    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 !!

  • nice and simple

Viewing 15 posts - 1 through 15 (of 29 total)

You must be logged in to reply to this topic. Login to reply