k80sg
k80sg

Reputation: 2473

store XML file data into a SQL XML datatype field

Do I store this XML file data into a SQL XML datatype field?

How do I write to it without writing into a XML file?

Upvotes: 1

Views: 262

Answers (2)

Shivprasad Koirala
Shivprasad Koirala

Reputation: 28596

If you want to store in SQL Server better use the XML data type as you get advantage of checking the type with XSD schema.

Upvotes: 0

user989818
user989818

Reputation:

Its not clear to me what you want. But you can store the xml file into a xml field and manipulate this field whatever you want.

Oracle database allows you to create a table based on a xml file, and changes on the table reflect over the xml file, you cant do that in SQL Server.

Anyway, you can manipulate a xml field like this:

declare @friends xml

set @friends =
'
<friends>
    <friend>
        <id>3</id>
    </friend>
    <friend>
        <id>6</id>
    </friend>
    <friend>
        <id>15</id>
    </friend>
</friends>
'

select
    template.item.value('.', 'bigint') as id
from @friends.nodes('//friends/friend/id') template(item)

Upvotes: 2

Related Questions