Solved

Load XML file into a SQL Server Table using SSIS 2012

Posted on 2016-09-06
9
56 Views
Last Modified: 2016-09-29
HI!

I'd need to load data from an XML(1.0) file into a SQL Server 2012 Table. It has multiple request and response data elements. What would be the best possible approach in terms of logic and performance. All the data needs to be loaded into just one table.The filename and elements should not be hardcoded.

Any logic/code is greatly appreciated.

Thanks a million in advance for your help!
0
Comment
Question by:amukta
  • 3
  • 3
  • 2
9 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41787208
as a start you can explore to XQuery Language Reference.

XQuery Language Reference (SQL Server)
https://msdn.microsoft.com/en-us/library/ms189075.aspx
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41789254
@amukta,

in addition, you can tell us how's your xml source and table looks like.
0
 

Author Comment

by:amukta
ID: 41791400
Is there anyway we can load XML file into a SQL server table, using SQL Script and SSIS without using bulk load, as we do not have bulk load permissions on the servers.l
0
 
LVL 46

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41791412
BULK command it's also available in T-SQL so you won't need a command line tool like bcp.
INSERT INTO XMLTable(XMLColumn)
SELECT CONVERT(XML, ImportedColumn)
FROM OPENROWSET(BULK 'C:\DataFile.xml', SINGLE_BLOB) AS x

Open in new window

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41795383
@amukta,

what Vitor suggested in comment ID: 41791412 should work for you as it runs well in SSIS package as well. but it also depends on how your XML looks like so that you may build in the logic how you extract the data from your XML file.
0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 41817267
Amukta, a feedback will be appreciated.
Cheers
0
 

Author Comment

by:amukta
ID: 41822844
We do not have permissions to perform the bulk load operation.Could you please as to how can the above code you've posted be used in SSIS?
0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 41822994
You'll need INSERT and ADMINISTER BULK OPERATIONS permissions to run the BULK command.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now