Insert XML data to a XML type column : XML « XML « SQL Server / T-SQL Tutorial






2> CREATE TABLE dbo.Contacts
3> (
4>   contactid       INT          NOT NULL PRIMARY KEY,
5>   contactname     NVARCHAR(50) NOT NULL,
6>   I18N        BIT          NOT NULL,
7>   otherattributes XML          NOT NULL
8> );
9> GO
1>
2>
2> INSERT INTO dbo.Contacts VALUES(1, 'Mike', 1, N'<I18N xmlns="I18N"><ID>1</ID><FL>S</FL></I18N>');
3> INSERT INTO dbo.Contacts VALUES(2, 'Her',  0, N'<Foreigns xmlns="Foreign"><NL>German</NL><ENG>1</ENG></Foreigns>');
4> INSERT INTO dbo.Contacts VALUES(3, N'Richard', 1, N'<I18N xmlns="I18N"><ID>2</ID><FL>German</FL></I18N>');
5> INSERT INTO dbo.Contacts VALUES(4, N'Gianluca', 0, N'<Foreigns xmlns="Foreign"><NL>Italian</NL><ENG>1</ENG></Foreigns>');
6> GO

(1 rows affected)

(1 rows affected)

(1 rows affected)

(1 rows affected)
1>
2> drop table dbo.Contacts;
3> GO








24.1.XML
24.1.1.XML type column
24.1.2.Insert XML data to database
24.1.3.Insert XML data to a XML type column
24.1.4.Creating xml Data Type Columns and insert data
24.1.5.Create index on XML column
24.1.6.Load XML data from a file to table
24.1.7.Modifying XML Data