1
kudos
spam Kudos Remove

SSIS - XML Source Script

published 685 days, 23 hours, 18 minutes ago posted by sasa 694 days, 23 hours, 56 minutes ago
Sunday, March 21, 2010 5:35:37 AM GMT Friday, March 12, 2010 4:57:12 AM GMT

The XML Source in SSIS is great if you have a 1 to 1 mapping between entity and table. You can do more complex mapping but it becomes very messy and won't perform. What other options do you have?

The challenge with XML processing is to not need a huge amount of memory. I remember using the early versions of Biztalk with loaded the whole document into memory to map from one document type to another. This was fine for small documents but was an absolute killer for large documents.

You therefore need a streaming approach.

For flexibility however you want to be able to generate your rows easily, and if you've ever used the XmlReader you will know its ugly code to write.

That brings me on to LINQ. The is an implementation of LINQ over XML which is really nice. You can write nice LINQ queries instead of the XMLReader stuff. The downside is that by default LINQ to XML requires a whole XML document to work with. No streaming.

Your code would look like this. We create an XDocument and then enumerate over a set of annoymous types we generate from our LINQ statement

x = XDocument.Load("C:\\TEMP\\CustomerOrders-Attribute.xml");

(var xdata

category: News | clicked: 0 | | source: sqlblogcasts.com | show counter code
tags: c#, SQL Server 2005, SQL Server 2008, SSIS - Integration Services, Tips and Tricks, XML

No comments yet, be the first one to post comment.

To post your comment please login or signup