Solved

load xml file into a database so that I can see the data that is in the XML file

Posted on 2014-10-17
2
117 Views
Last Modified: 2014-10-17
Hi,
We have a very large xml file called GMEIIssuedFullFIle.xml

What would the SQL code be to...
load the file into a test database so that we can view the data that is in the xml file.

Thanks for your help in advance
0
Comment
Question by:tesla764
2 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 40387006
You could do that for instance like in the query below assuming you know the structure of your XML doc:

CREATE TABLE [dbo].XMLtable_load(
      [bip] [varchar](10) NULL,
      [Doc_TYPE] [varchar](50) NULL,
      [Doc] [text] NULL,
      [ID] [varchar](50) NULL,
      [rowOrder] [int] NULL,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


INSERT INTO XMLtable_load (bip,doc_type,doc,id,roworder)
 SELECT X.bip.query('bip').value('.', 'VARCHAR(10)'),      
 X.bip.query('Doc_TYPE').value('.', 'VARCHAR(50)'),
 X.bip.query('Doc').value('.', 'VARCHAR(8000)'),
 X.bip.query('@ID').value('.', 'VARCHAR(50)'),
 X.bip.query('@rowOrder').value('.', 'INT')
 FROM
 ( SELECT CAST(x AS XML)FROM OPENROWSET(     BULK 'C:\Downloads\BipDocs.xml', SINGLE_BLOB) AS T(x)     )
 AS T(x)CROSS APPLY x.nodes('Root/bip_Doc') AS X(bip);
0
 

Author Closing Comment

by:tesla764
ID: 40387529
Thanks. That was very helpful.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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