sp_xml_preparedocument gehen mit Fehler "only one top level element is allowed in ein XML-Dokument"

Ich bin versucht zu führen sp_xml_preparedocument und geting Fehlermeldung "only one top level element is allowed in ein XML-Dokument"

mein T-SQL-Befehle:

DECLARE @aa XML
DECLARE @idoc int
SET @aa =(select * from db_name for xml auto, xmldata) 

@aa ist jetzt

<Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes" name="Schema7">
<ElementType name="Person" content="empty" model="closed">
  <AttributeType name="preson_id" dt:type="i4" />
  <AttributeType name="Name" dt:type="string" />
  <AttributeType name="Surname" dt:type="string" />
  <AttributeType name="guid" dt:type="uuid" />
  <AttributeType name="version" dt:type="bin.base64" />
  <attribute type="preson_id" />
  <attribute type="Name" />
  <attribute type="Surname" />
  <attribute type="guid" />
  <attribute type="version" />
 </ElementType>
</Schema>
  <Person xmlns="x-schema:#Schema7" preson_id="1" Name="Иван" Surname="Иванов" guid="2E739E87-3CA4-4ED8-ADD0-8B59957668B8" version="AAAAAAAAB9E=" />
  <Person xmlns="x-schema:#Schema7" preson_id="2" Name="Николай" Surname="Николаев" guid="BDC41C59-D70F-4B70-954E-4918B9516AF8" version="AAAAAAAAB9I=" />
  <Person xmlns="x-schema:#Schema7" preson_id="3" Name="Максим" Surname="Максимов" guid="740E57F3-56BA-48B8-92AF-978D7B1D2712" version="AAAAAAAAB9M=" />

EXEC sp_xml_preparedocument @idoc OUTPUT, @aa

The XML parse error 0xc00ce555 occurred on line number 1, near the XML text ""
Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1
The error description is 'Only one top level element is allowed in an XML document

Ich bin neu in diesem, und ich brauche Hilfe)))
Eine mehr Frage - Wie parse Typ timestamp?

wenn ich

SET @aa =(select * from db_name for xml elements, root('root'), type) 

sp_xml_preparedocument funktioniert, OPENXML gibt alle Werte, die ich db_table, aber timestamp-Werte sieht nicht das gleiche wie..

Sorry für mein schlechtes Englisch

  • Setzen Sie das zweite Teil re Zeitstempel als eine separate Frage, wie es erfordert eine andere Antwort
InformationsquelleAutor amigo | 2011-01-19
Schreibe einen Kommentar