I’m using SQL Server 2008 R2 and have a simple table with a column of data type XML. I have created an XML Schema document that correctly validates the XML data that will be stored. My questions are:
-
How can I assign the schema to column such that it will validate the XML and reject the insert if it fails the schema?
-
Is the schema required in order to add an XML Index to the column or can XML Indices be added without the schema doc?
To create a schema collection, you can use the following:
Then, apply it with:
Referenced from: http://technet.microsoft.com/en-us/library/ms176009.aspx
This example shows you do not need to have a schema on your XML for you to be able to index the column: http://msdn.microsoft.com/en-us/library/bb510443.aspx