Sql Server 2008 Standard:
To isolate the problem I'm having, I've created a simple Dbs with just one
table, having an "int" field and an "xml" field.
The xml field is assigned to a SchemaCollection, so it is typed.
Updating the xml field with XML data works 99.99 of the times, but I have 2
specific XML fragments that systematically give me problems. Updating the xml
field in the table with this data works fine without errors, however when I
do a SELECT * from the table in the Management Studio, I get the error:
"An error occurred while executing batch. Error message is: Index was
outside the bounds of the array."
Changing "SELECT xmlField FROM tab" to "SELECT CAST(xmlField AS
nvarchar(MAX)) FROM tab" appears to give me the correct xml string, so the
data is there!
Querying the data from .Net code gives the same error. Here's part of the
stack trace:
[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Xml.XmlSqlBinaryReader.GetXsdKatmaiTokenLen gth(BinXmlToken token)
+1207761
System.Xml.XmlSqlBinaryReader.ScanOverAnyValue(Bin XmlToken token, Boolean
attr, Boolean checkChars) +524
System.Xml.XmlSqlBinaryReader.ScanOverValue(BinXml Token token, Boolean
attr, Boolean checkChars) +159
System.Xml.XmlSqlBinaryReader.ImplReadData(BinXmlT oken tokenType) +119
System.Xml.XmlSqlBinaryReader.ReadDoc() +589
System.Xml.XmlSqlBinaryReader.Read() +201
I get this exact problem on different machines: both the production Server
2003 and my Vista development PC.
I've been successfully using XML fields in SQL2005 for 3 years now, and have
recently upgraded to SQL2008.
This has me completely puzzled.
Is there any known problem that might be related or anyone has a queue how
to fix this? Would be warmly appreciated.
Thanks