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