RE: how to import an xml file to sql
- From: Dee <Dee@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Jan 2008 16:22:00 -0800
OK, I will use this. Is this the output you want me to send back to your.
Also I think there are other fields I will have to add.
Thanks
Dee
"ML" wrote:
Ooopsss!.
Here's the corrected query:
declare @xml varchar(max)
declare @xmlHandle int
-- Bulk load the xml from the file
set @xml = (
select *
from openrowset
(
bulk 'D:\Temp\Products.xml'
,single_blob
) Products
)
-- Prepare the DOM document
exec sp_xml_preparedocument
@xmlHandle output
,@xml
-- Parse the XML
-- You can include this select statement in your insert statement
select *
from openxml
(
@xmlHandle
,'/Products/Product'
)
with (
id varchar(32) '@Id'
,code varchar(32) 'Code'
,[description] varchar(1024) 'Description'
,url varchar(1024) 'Url'
,orderable varchar(3) 'Orderable'
,taxable varchar(3) 'Taxable'
,[path] varchar(1024) 'Path'
,caption varchar(1024) 'Caption'
)
-- Never forget to remove the DOM document as soon as you're done using it.
exec sp_xml_removedocument
@xmlHandle
go
ML
---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com/
- References:
- RE: how to import an xml file to sql
- From: Dee
- RE: how to import an xml file to sql
- From: ML
- RE: how to import an xml file to sql
- Prev by Date: RE: how to import an xml file to sql
- Next by Date: Fact Table(s) Design Question
- Previous by thread: RE: how to import an xml file to sql
- Next by thread: RE: how to import an xml file to sql
- Index(es):
Relevant Pages
|
Loading