Working with the XML Data Type of SQL Server, Page 4
Here, you used a CREATE XML SCHEMA COLLECTION statement to create a schema collection named EmployeeSchemas. What follows is the actual schema that you want to attach. Once you create the schema collection, you can attach the schema as shown in Figure 14:
Figure 14: Attaching a schema to an XML column
Have a look at the XML Type Specification property for the EmployeeData column. Your schema collection EmployeeSchema is listed there. This is how you can attach an XSD schema to the XML column.
In this article, you were introduced to the basics of using the XML data type. The XML data type is a convenient way of storing XML documents and fragments in the SQL Server database itself. The XML DML allows you to query and modify the XML data in a variety of ways. To do so, XML DML heavily relies on XQuery syntax. The methods such as modify(), query(), value(), and exist() enable you to alter and query your XML data in variety of ways. The XML data also can have a schema attached with it that helps you to ensure validity of the XML data being stored.
About the Author
Bipin Joshi is the proprietor of BinaryIntellect Consulting, where he conducts premier training programs on .NET technologies. He wears many hats, including software consultant, mentor, prolific author, webmaster, Microsoft MVP, and member of ASPInsiders. Having adopted the Yoga way of life, Bipin also teaches Kriya Yoga to interested individuals. His detailed profile can be read on his blog. He also can be reached there.