Re: Importing xml through tsql
- From: "Michael Rys [MSFT]" <mrys@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 16 May 2005 06:55:04 -0700
Assuming you want the data in two different tables, you could write:
declare @h int
exec sp_xml_preparedocument @h output, N'<myfile>
<table1>
<col1>Value1</col1>
<col2>Value2</col2>
<col3>Value3</col3>
<col4>Value4</col4>
</table1>
<table2>
<col1>Value1</col1>
<col2>Value2</col2>
<col3>Value3</col3>
<col4>Value4</col4>
</table2>
</myfile>'
--insert into table1
select * from OpenXML(@h, '/myfile/table1',2)
with (col1 nvarchar(20),col2 nvarchar(20),col3 nvarchar(20),col4
nvarchar(20))
--insert into table2
select * from OpenXML(@h, '/myfile/table2',2)
with (col1 nvarchar(20),col2 nvarchar(20),col3 nvarchar(20),col4
nvarchar(20))
exec sp_xml_removedocument @h
HTH
Michael
"Mal .mullerjannie@xxxxxxxxxxx>" <<removethis> wrote in message
news:D66EB2F0-A4F4-4CAB-904C-B4550359905B@xxxxxxxxxxxxxxxx
> Hey
>
> I'm relatively new to xml.
> I want to upload xml data with sql's openxml. I can do it with "normal"
> xml
> but my files look a bit different and I can't find help on it.
>
> My file looks like this:
>
> <myfile>
> <table1>
> <col1>Value1</col1>
> <col2>Value2</col2>
> <col3>Value3</col3>
> <col4>Value4</col4>
> </table1>
> <table2>
> <col1>Value1</col1>
> <col2>Value2</col2>
> <col3>Value3</col3>
> <col4>Value4</col4>
> </table2>
> </myfile>
>
> Hope this makes sense.
>
> Thanks for the help.
>
.
- References:
- Importing xml through tsql
- From: Mal . mullerjannie
- Importing xml through tsql
- Prev by Date: Importing xml through tsql
- Next by Date: RE: SQLXMLBulkLoad
- Previous by thread: Importing xml through tsql
- Next by thread: RE: SQLXMLBulkLoad
- Index(es):
Relevant Pages
|