sql-serverxmlsql-server-2008xml-column

How is an xml column stored in SQL Server 2008?


I try to understand how SQL Server 2008 store xml columns in an attempt to estimate table size in our product.

I'm using DATALENGTH(xml_column) to run some test and results are disturbing :

Xml document length | Datalength | Bytes per character
175                 | 366        | 2.09
15                  | 38         | 2.53
314                 | 414        | 1.31

Obviously, the xml column type is not a nvarchar(max) in disguise, as I've read somewhere.

It's probably compacted and stored as binary, but a can't find how anywhere.

Can someone explain me how is an xml column stored in SQL Server 2008 ?


Solution

  • As pointed out by rene, SQL Server 2008 uses the MS-BINXML - a compact binary format - to store the content of xml columns.