Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



Yukon and For Xml Nesting

Posted in Sql and Xml at Thursday, February 19, 2004 7:28 AM Pacific Standard Time

Dr. Michael Rys has a great post up on how For Xml nesting will work in Yukon.

Obviously, this query is easier to write, understand and maintain. OTOH, due to the fact that we create intermediate XML objects, it may have worse performance characteristics (altough, sometimes it can be faster since we do not need the union and less joins).

I think the performance hit will be well worth it. Plus if you don't want to take the performance hit you can still use the explicit mode.

This nesting feature also looks like it could be useful for “fixing” something I run into when using Serialization. When I have a collection that I want to populate using a FOR XML query, I've found that you need the root element to be in the form of "ArrayOfType" where "Type" is the type of objects that make up the collection. In order to create the root element I use a simple view:

create view EmptyParentView as select '' as Parent

Then I join this view with my table in a FOR XML AUTO select query:

select Parent as IgnoreMe, -- Ingore this element
from EmptyParentView as ArrayOfReport,
 Reports as Report
for xml auto, elements

This gives me an Xml result that can be deserialized into a collection. Would nesting help me? Maybe not since I really wouldn't be able to specify the root element type. Comments?


Comments are closed.