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

Home
SQL Server / T-SQL Tutorial
1.Query
2.Insert Delete Update
3.Table
4.Table Join
5.Data Types
6.Set Operations
7.Constraints
8.Subquery
9.Aggregate Functions
10.Date Functions
11.Math Functions
12.String Functions
13.Data Convert Functions
14.Analytical Functions
15.Sequence Indentity
16.View
17.Index
18.Cursor
19.Database
20.Transact SQL
21.Procedure Function
22.Trigger
23.Transaction
24.XML
25.System Functions
26.System Settings
27.System Tables Views
28.User Role
29.CLR
SQL Server / T-SQL Tutorial » XML » XML 
24.1.3.Insert XML data to a XML type column
2CREATE TABLE dbo.Contacts
3(
4>   contactid       INT          NOT NULL PRIMARY KEY,
5>   contactname     NVARCHAR(50NOT NULL,
6>   I18N        BIT          NOT NULL,
7>   otherattributes XML          NOT NULL
8);
9> GO
1>
2>
2INSERT INTO dbo.Contacts VALUES(1'Mike', 1, N'<I18N xmlns="I18N"><ID>1</ID><FL>S</FL></I18N>');
3INSERT INTO dbo.Contacts VALUES(2'Her',  0, N'<Foreigns xmlns="Foreign"><NL>German</NL><ENG>1</ENG></Foreigns>');
4INSERT INTO dbo.Contacts VALUES(3, N'Richard', 1, N'<I18N xmlns="I18N"><ID>2</ID><FL>German</FL></I18N>');
5INSERT INTO dbo.Contacts VALUES(4, N'Gianluca', 0, N'<Foreigns xmlns="Foreign"><NL>Italian</NL><ENG>1</ENG></Foreigns>');
6> GO

(rows affected)

(rows affected)

(rows affected)

(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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.