Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML in SQL Server 2005? Better than JSON in Varchar?

What are the benefits of storing XML in SQL Server over storing JSON in a varchar field?

Any tutorial available for how to use the XML data type effectively?

Do I need to provide the dtd / xml schema somehow? I've heard it is optional, right?

Thank you.

UPDATE: here's the answer to the last part of the Q.

XML schema information is used in storage and query optimizations. Typed XML instances contain typed values in the internal, binary representation as well as in XML indexes. This provides efficient processing of typed XML data.

quoted from: http://msdn.microsoft.com/en-us/library/ms345117(SQL.90).aspx

like image 412
Henry Avatar asked Mar 22 '26 04:03

Henry


1 Answers

XML in SQL Server 2005 and up allows you to directly manipulate the XML stored inside the database table using XQuery - you can't really do that with JSON in a VARCHAR field.

Check out XML Support in Microsoft SQL Server 2005 and Fundamentals of the XML Datatype in SQL Server 2005 for more info and more background.

Also, the XML stored in a XML column in SQL Server is "tokenized" and pre-parsed - it's not just stored as plain text. And you can even put indices on your XML - on its nodes, its values - whatever you need.

like image 112
marc_s Avatar answered Mar 24 '26 19:03

marc_s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!