Solved

Load XML file into a SQL Server Table using SSIS 2012

Posted on 2016-09-06
9
47 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 45

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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 45

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 45

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

My client sends data in an Excel file to me to load them into Staging database. The file contains many sheets that they have same structure. In this article, I would like to share the simple way to load data of multiple sheets by using SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

757 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

22 Experts available now in Live!

Get 1:1 Help Now