Character Data as XML

XML, in all its dialects, is stored ultimately as string (character) data. Before the xml data type, XML data could only be stored in SQL Server using ordinary string data types, such as varchar(max) and text, and doing so raises several challenges. The first issue is validating the XML that is persisted (and by this we mean validating the XML against an XSD schema). SQL Server has no means of performing such a validation using ordinary strings, so the XML data can’t be validated except by an outside application which can be a risky proposition (the true power of a relational database management system, or RDBMS, is applying rules at the server level).

The second issue is querying the data. Sure, you could look for data using ...

Get Programming Microsoft® SQL Server® 2012 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.