Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Import XML Data into SQL tables


Import XML Data into SQL tables

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

Group: General Forum Members
Points: 29 Visits: 176
Hello,
I have about 6000 XML files need to import data to SQL tables. The data is not in specific fromat. End users filled Infopath forms and saved as XML document. Now i need to find out those fields and create new tables the import data.

I tried using SSIS but when i locate XML file in XML source it says "Xml Source adaptor does'nt support mixed content model on complex types". I think data more comples for SSIS to handle. But i cant do anything with data.

Is there any other option to import XML data like Queries or stored procs in SSMS. I heared that we can do in XQuery, but not sure.

please reply me if anyone get idea about this..

Thanks in advance!
Kumar
GSquared
GSquared
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14387 Visits: 9729
Your best best is bulk-import the files into an XML datatype column, and then parse them out with XQuery.

If you aren't familiar with querying XML data, this will not be easy. You may want to talk to management about bringing in a contractor to do the job for you.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
SGT_squeequal
SGT_squeequal
SSC Veteran
SSC Veteran (276 reputation)SSC Veteran (276 reputation)SSC Veteran (276 reputation)SSC Veteran (276 reputation)SSC Veteran (276 reputation)SSC Veteran (276 reputation)SSC Veteran (276 reputation)SSC Veteran (276 reputation)

Group: General Forum Members
Points: 276 Visits: 1047
im no XML expert but, i use this command to import xml files in to my database, I created a SP using the dynamic SQL so i can pass it a location and file name.




insert into #xml_table SELECT * FROM OPENROWSET(BULK N'c:\temp\filename.xml', SINGLE_CLOB) AS xmldata



set @XML_exec ='insert into #xml_table SELECT * FROM OPENROWSET(BULK N'+char(39)+@file+char(39)+', SINGLE_CLOB) AS xmldata'

Exec (@XML_exec)




*************************************************************

The first is always the hardestw00t
Matt Miller (#4)
Matt Miller (#4)
SSCertifiable
SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)

Group: General Forum Members
Points: 7664 Visits: 18097
You probably will want to find out where the mixed content actually is. Mixed content tends to be problematic no matter what in just about any xml handling, since it sets up some room for ambiguous answers on how to return nodes with mixed content.

As a matter of background, XML mixed content is where you have BOTH text AND children nodes in a given element. So you're looking for something that might look like:


<root>
<mixedcontentnode>
The <operator value="Cow"/> Jumped over the <actionObject val="moon"/>.
</mixedcontentnode>
</root>



In short you will find a lot of xquery engines having a rough time figuring out what to return with they are asked for the text() out of the mixedcontentnode above.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Kumar SQL
Kumar SQL
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 176
Thank you all for reply!

thing is that i dont have Bulk Insert permissions. Can we do it by writing C# code using Script task in SSIS?

Kumar
GSquared
GSquared
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14387 Visits: 9729
Probably. I'm not as familiar with script tasks in SSIS as I probably should be. But why not get your SSIS package assigned a credential with bulk-import permissions? That would be the easiest solution.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
durga.palepu
durga.palepu
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 Visits: 220
Matt Miller,

Thanks a lot, its solved the issue which I am struggling for last 2 days!!
Pat-427049
Pat-427049
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 80
Hi

So what was your solution here? We're having a similar problem that we are trying to resolve.

Thanks,
Patrick
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