How to Insert XML Data directly into a SQL Server Table

To create a test table with an Identity column, and a column of XML data type use the following code:

CREATE TABLE XML_Test_Table
(
Id INT IDENTITY PRIMARY KEY,
XMLData XML
)

You can insert XML data directly into the table using the INSERT command:

insert_into_xml_directly

As you can see, XML data is inserted into the XMLData column:

SELECT * FROM XML_Test_Table

insert_xml_directly

Clicking on the hyperlink open a tab in SSMS with the XML data:

insert_xml_directly_data

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">