Multiple outputs from XML Source

  • Hi,

    I'm trying to load xml data into sql table using xml source, the file has around 6000 fileds. When i click on columns in XML source editor i see mutiple outputs each having set of available columns.Now when i connect source to destionation it asking me to select one output from above available outputs.Do we have any option to select all outputs at a time and load into destination? I have around 80 outputs like that.

    First time i come across with this scenario,Can anyone please suggest on this?

    Thanks,

    Kumar

  • -- load file into xml variable

    DECLARE @x xml

    SELECT @x = CAST(c1 as xml)

    FROM OPENROWSET(BULK 'D:\temp\sampledata.xml', SINGLE_CLOB) t1(c1)

    --turn xml into table with nodes() function:

    declare @xml as xml = '

    <ArrayOfCustomers

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    >

    <Customer id="1">

    <CustomerName>Mr Smith</CustomerName>

    <Children>

    <Child ChildName="Peter" />

    <Child ChildName="Ivan" />

    </Children>

    </Customer>

    <Customer id="2">

    <CustomerName>Mr Bloggs</CustomerName>

    <Children>

    <Child ChildName="John" />

    </Children>

    </Customer>

    </ArrayOfCustomers>

    '

    SELECT AOC.Cust.value('.','varchar(max)')

    FROM @xml.nodes('/ArrayOfCustomers/Customer') AS AOC(Cust)

    HTH,

    Vedran

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • If you have a complex XML file and SSIS detects 80 outputs then you'll have to process each of the 80 outputs in some form or manner if you want the data loaded somewhere. How do you suppose SSIS could process 80 outputs into one Destination if each output has a different set of fields or different data types?

    Maybe you could look into the Bulk XML Loader built into SQLXML. With it you can provide a specialized xsd and the loader will automatically bring the XML into tables you define in the xsd.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 3 posts - 1 through 2 (of 2 total)

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