How is an xml column stored in SQL Server 2008?

2k Views Asked by At

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 ?

2

There are 2 best solutions below

0
On BEST ANSWER

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

4
On

An XML column is stored in a "compact binary format".

I doubt that Microsoft will give you any more detail than that.