Creating xml Data Type Columns and insert data : XML « XML « SQL Server / T-SQL Tutorial

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
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » XML » XML 
24. 1. 4. Creating xml Data Type Columns and insert data
5>
6>  CREATE TABLE dbo.Book(
7>  BookID int IDENTITY(1,1PRIMARY KEY,
8>  ISBN char(10NOT NULL,
9>  BookName varchar(250NOT NULL,
10>  AuthorID int NOT NULL,
11>  ChapterDESC XML NULL)
12>  GO
1>
2>  CREATE PROCEDURE dbo.usp_INS_Book
3>  @ISBN char(10),
4>  @BookName varchar(250),
5>  @AuthorID int,
6>  @ChapterDESC xml
7>  AS
8>  INSERT dbo.Book
9>  (ISBN, BookName, AuthorID, ChapterDESC)
10>  VALUES (@ISBN, @BookName, @AuthorID, @ChapterDESC)
11>  GO
1>
2> --Inserting xml Data into a Column
3>
4INSERT dbo.Book
5(ISBN, BookName, AuthorID, ChapterDESC)
6> VALUES ('1111','SQL Server',55,
7> CAST('<Book name="SQL Server">
8~ <Chapters>
9~ <Chapter id="1"> a </Chapter>
10~  <Chapter id="2"> b </Chapter>
11~  <Chapter id="3"> c </Chapter>
12~  <Chapter id="4"> d </Chapter>
13~  <Chapter id="5"> e </Chapter>
14~  <Chapter id="6"> f </Chapter>
15~  </Chapters>
16~  </Book>' as XML))
17>  GO

(rows affected)
1>
2>
3select from dbo.book
4> GO
BookID      ISBN       BookName
                                                                          AuthorID    ChapterDESC

----------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------- ----------- ------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------
          1 1111       SQL Server
                                                                                   55 <Book name="SQL Server"><Chapters><Chapter id="1"> a </Chapter><Chapter id="2"> b </Chapter><Chapter id="3"> c </C
hapter><Chapter id="4"> d </Chapter><Chapter id="5"> e </Chapter><Chapter id="6"> f </Chapter></Chapters></Book>

(rows affected)
1> drop table dbo.book
2> GO
1>
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.