Shred XML to SQL 2005

Shred XML to SQL 2005

am 26.12.2007 15:26:30 von bochumer.szene

I am absolute a novice in XML but need to shred XML into SQL Server
2005.
I studied some examples, but only with simple XML Docs.
My docs seems to be looking more complex.

Maybe someone can point me into the right direction:


My XML looks like this:








asdasdasd
12345
Somewhere
GERMANY
555-555-555

0
0


Bus



Subway







9583718
Metropolis



Metropolis

302



Dolby SR



52015561

12.12.07



N
12.12.2007


45408016

12.12.07



N
12.12.2007









Verwünscht
55268869
Enchanted

Amy Adams
Patrick Dempsey
James Marsden


Kevin Lima


Bill Kelly

108
2007
USA
n

Die bildschöne Giselle wird kurz vor ihrer
Märchenhochzeit von ihrer Stiefmutter aus dem magischen
Zeichentrickreich Andalasia nach Manhattan verbannt. Hilflos und ganz
auf sich allein gestellt, läuft sie einem smarten Scheidungsanwalt in
die Arme, der sie bei sich aufnimmt. Als sich die beiden langsam
näherkommen, taucht Giselles Märchenprinz auf, um sie
zurückzuholen. LONG_DESCRIPTION>
Enchanted


Fantasy
Liebesfilm


FSK
oA


Kinderfilm
n



Re: Shred XML to SQL 2005

am 27.12.2007 00:11:20 von Erland Sommarskog

Theo Müller (bochumer.szene@googlemail.com) writes:
> I am absolute a novice in XML but need to shred XML into SQL Server
> 2005.
> I studied some examples, but only with simple XML Docs.
> My docs seems to be looking more complex.
>
> Maybe someone can point me into the right direction:

Since I don't know what you what you want to get out of the document,
I can't give you any code.

In general, there are two methods: OPENXML and XQuery. OPENXML is
the older method, introduced in SQL 2000, XQuery was added in SQL 2005.
XQuery is a standardised language to query XML documents, not only
in SQL Server.

OPENXML may be easier to get started with, but I since XQuery is newer,
I think it's better in the long run. Then again, I have seen situations
where the performance XQuery have been outright poor with element-
centred XML which is what you have.

Both OPENXML and XQuery are described in Books Online, and you could
start reading, but of course if you are completely new to XML, the
learning curve may be a bit steep.

Unfortunately, I cannot really give good recommendations on books. I
learnt XML myself from "XML Step by Step" by Michael Yuong and
"Programming Microsoft SQL Server 2000 with XML" by Graeme Malcolm.
The latter book is definitely dated by now, unless the author has an
update for SQL 2005. The former book is a little more timeless, and
is good enough to learn you what XML is, but it will not teach you
XQuery. Unless, again, there is a newer edition; my copy is several
years old.




--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx

Re: Shred XML to SQL 2005

am 28.12.2007 15:02:38 von bochumer.szene

On 27 Dez., 00:11, Erland Sommarskog wrote:
> Theo Müller (bochumer.sz...@googlemail.com) writes:
> > I am absolute a novice inXMLbut need toshredXMLintoSQLServer
> > 2005.
> > I studied some examples, but only with simpleXMLDocs.
> > My docs seems to be looking more complex.
>
> > Maybe someone can point me into the right direction:
>
> Since I don't know what you what you want to get out of the document,
> I can't give you any code.
>

thanks for your reply.
quite easy speaking, i want to 'import' the xml to tables. But because
of the structure of the xml, i don't know how to do.
THere is a different sample in this group, with a 'easy' xml doc. i
understandn how to do it with that one....

so maybe its a bit more clear now.

BR

Re: Shred XML to SQL 2005

am 28.12.2007 23:32:00 von Erland Sommarskog

Theo Müller (bochumer.szene@googlemail.com) writes:
> thanks for your reply.
> quite easy speaking, i want to 'import' the xml to tables. But because
> of the structure of the xml, i don't know how to do.


And I don't know the tables, nor which elements you want there, so I
don't know either.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx