Header Ads

SQL Server 2005 introduces a new data type called XML which allows you to store XML data. SQL Server supports XQuery for querying against XML data, including extensions that allow DDL operations.
One can add xml fragments and documents to SQL Server 2000 using a text or ntext data type. However, the new xml data type allows one to assign a schema collection to the xml column as well as use XQuery in your Queries. So, if the user tries to enter the xml data which violates the schema which throws an error.

Before you can assign the Book Collection schema to the column, you need to add the schema to the SQL Server 2005. You can create the schema as below, which allows entering the valid data into database. So, the input can be as below:

Schema for the above data:

So, to insert XML data into the table Books.

As mentioned earlier, any XML that you try to enter into the “TableOfContents” column that does not match the schema, which will throw an error. So, only valid XML data can be entered to accommodate the column.
The new VARCHAR(MAX), NVARCHAR(MAX), VARBINARY(MAX) data types can hold 2 GB of data and are useful alternatives to the varchar, nvarchar, ntext, and image data types.

No comments:

Powered by Blogger.