I am using SSIS in Visual Studio 2008. I have many XML files that I need to process and place into an existing DB structure (SQL Server 2005). This is my first attempt at using SSIS and am a little stuck. I have found the XML Data Flow task, assigned it a test xml file and it’s associated XSD, and mapped one node to a Database Table. My question is, how do I associate many xsd nodes with many tables? Surely I don’t have to set up an XML source for each table?
Share
Here is a possible option which demonstrates how to load multiple XML files having same definition into an SQL Server table. The example uses
SQL Server 2008 R2andSSIS 2008 R2. The example shown here loads three XML files into an SQL table using SSISData Flow Taskwith the help ofXML Sourcecomponent.Step-by-step process:
dbo.Itemsusing the script given under SQL Scripts section.Items.xsdin the folder path C:\temp\xsd using the content provided under XSD File section.Items_1.xml,Items_2.xmlandItems_3.xmlin the folder path C:\temp\xml using the content provided under XML Files section.FileExtension,FilePathandFolderPathas shown in screenshot #1.SQLServerto connect to the SQL Server Instance as shown in screenshot #2.Control Flowtab, place aForeach loop containerand aData Flow Taskwithin the Foreach loop container as shown in screenshot #3.Foreach Loop containeras shown in screenshots #4 and #5.Data Flow Taskto navigate to theData Flowtab. Place anXML Sourcecomponent and anOLE DB Destinationas shown in screenshot #6.XML Sourceas shown in screenshot #7 and #8. The XML file path will be retrieved from the variable FilePath. This variable will be populated by theForeach Loop container.OLE DB Destinationas shown in screenshots #9 and #10.dbo.Itemsnow contains the data present in three XML files.Hope that helps.
SQL Scripts:
XSD File
XML Files
Items_1.xml
Items_2.xml
Items_3.xml
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
Screenshot #5:
Screenshot #6:
Screenshot #7:
Screenshot #8:
Screenshot #9:
Screenshot #10:
Screenshot #11:
Screenshot #12:
Screenshot #13:
Screenshot #14: