SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Multiple outputs from XML Source


Multiple outputs from XML Source

Author
Message
Kumar SQL
Kumar SQL
SSC Rookie
SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)SSC Rookie (47 reputation)

Group: General Forum Members
Points: 47 Visits: 176
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
Vedran Kesegic
Vedran Kesegic
Right there with Babe
Right there with Babe (738 reputation)Right there with Babe (738 reputation)Right there with Babe (738 reputation)Right there with Babe (738 reputation)Right there with Babe (738 reputation)Right there with Babe (738 reputation)Right there with Babe (738 reputation)Right there with Babe (738 reputation)

Group: General Forum Members
Points: 738 Visits: 1266
-- 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

Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15339 Visits: 14396
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search