Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Import XML Data into SQL tables Expand / Collapse
Author
Message
Posted Thursday, July 12, 2012 11:13 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, September 25, 2014 10:29 AM
Points: 21, Visits: 167
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
Post #1329055
Posted Thursday, July 12, 2012 11:29 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 13,872, Visits: 9,596
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
Post #1329065
Posted Thursday, July 12, 2012 12:54 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 8, 2014 2:40 PM
Points: 271, Visits: 1,020
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 hardest
Post #1329120
Posted Thursday, July 12, 2012 2:49 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:07 PM
Points: 7,105, Visits: 15,433
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?
Post #1329176
Posted Friday, July 13, 2012 10:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, September 25, 2014 10:29 AM
Points: 21, Visits: 167
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
Post #1329583
Posted Thursday, July 19, 2012 6:55 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 13,872, Visits: 9,596
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
Post #1332151
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse