?
Solved

Load XML file into a SQL Server Table using SSIS 2012

Posted on 2016-09-06
9
Medium Priority
?
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
9 Comments
 
LVL 53

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 53

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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 51

Accepted Solution

by:
Vitor Montalvão earned 2000 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
 
LVL 53

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 51

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 51

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

771 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