Wednesday, March 21, 2012

from xml file to sql server table

Hello; I'm very newbe about XML and I0m sorry for the question; I would like
to begin the "management" of XML data but I'm a lot ; I would like t
o
start with a simple example about an import/insert process from a xml file t
o
a sql server table. I often read example about, but even only a portion of
the xml file was "hard coded" in the script; I would like to import the whol
e
file, not only a portion.
Best regards and thanks in advance.
Bruno StefanuttiHello consept,

> Hello; I'm very newbe about XML and I0m sorry for the question; I
> would like to begin the "management" of XML data but I'm a lot
> ; I would like to start with a simple example about an
> import/insert process from a xml file to a sql server table. I often
> read example about, but even only a portion of the xml file was "hard
> coded" in the script; I would like to import the whole file, not only
> a portion.
Here you go:
drop table dbo.t
go
create table dbo.t(pkid tinyint identity(1,1), x xml)
go
insert into dbo.t(x)
select t.c from
openrowset(bulk 'c:\somefile.xml',SINGLE_BLOB) as t(c)
go
select x from dbo.t
Thank you,
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/|||Dear Kent,
thanks for the help but there is some problems; for example the system said
"type xml unknow in row 3"...Also, in openrowset(bulk...) instruction the
system disagrees..I don't know. Do you have some more simple example? I'm
sorry
Thanks in advance.
Bruno
"Kent Tegels" wrote:

> Hello consept,
>
> Here you go:
> drop table dbo.t
> go
> create table dbo.t(pkid tinyint identity(1,1), x xml)
> go
> insert into dbo.t(x)
> select t.c from
> openrowset(bulk 'c:\somefile.xml',SINGLE_BLOB) as t(c)
> go
> select x from dbo.t
> Thank you,
> Kent Tegels
> DevelopMentor
> http://staff.develop.com/ktegels/
>
>|||You need SQL Server 2005 to get the code below to work.
Best regards
Michael
"consept" <consept@.discussions.microsoft.com> wrote in message
news:D1FFC724-BD47-43BF-999F-CB954E07F60D@.microsoft.com...
> Dear Kent,
> thanks for the help but there is some problems; for example the system
> said
> "type xml unknow in row 3"...Also, in openrowset(bulk...) instruction the
> system disagrees..I don't know. Do you have some more simple example? I'm
> sorry
> Thanks in advance.
> Bruno
> "Kent Tegels" wrote:
>sql

No comments:

Post a Comment