1

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?

1

2 Answers 2

2

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)
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.