I'm playing around and learning to use Microsoft SQL Server. I want to store XML documents in a table, parts of the XML document won't be modified within the table (i.e. any changes will be done by updating the whole XML document in that cell).
From what I can see, I can store the XML documents in a column of type Xml or in a varchar(MAX).
What are the pros and cons of each?
XML (eXtensible Markup Language) is one of the most common formats used to share information between different platforms. Owing to its simplicity and readability, it has become the de-facto standard for data sharing. In addition, XML is easily extendable.
XML Database is used to store huge amount of information in the XML format. As the use of XML is increasing in every field, it is required to have a secured place to store the XML documents. The data stored in the database can be queried using XQuery, serialized, and exported into a desired format.
The xml data type is a built-in data type in SQL Server and is somewhat similar to other built-in types such as int and varchar. As with other built-in types, you can use the xml data type as a column type when you create a table as a variable type, a parameter type, a function-return type, or in CAST and CONVERT.
XML is a format to store data along with its structure. This feature makes it useful for many things, including transferring data, formatting documents, creating layouts, and more.
XML datatype supports:
Besides, using an XML type it will be harder for you to do the typical mistakes junior developers do when handling XML: threat it as a string, mix or ignore encodings like UTF8 and UTF16, ignore namespaces, confuse or ignore processing instructions etc etc.
Please read XML Best Practices for Microsoft SQL Server 2005
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With