Solved

Load XML file into a SQL Server Table using SSIS 2012

Posted on 2016-09-06
9
75 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 50

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 50

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 47

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
 
LVL 50

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 47

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 47

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SqlServer no dupes 25 34
How To Convert Date Stored as Varchar as an MSSQL DATE Type Field In a VIEW 3 21
VB.net and sql server 4 33
sql server tables from access 18 17
My client has a dictionary table. They're defining a list of standard naming convention. Now, they are requiring my team to provide us a mechanism how to match new incoming data with existing data in their system.
Here's a requirements document template for an integration project (also known as Extract-Transform-Load or ETL) based on my development experience as an SQL Server Information Services (SSIS) developer over the years.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

786 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