home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,303 of 19,505   
   Erland Sommarskog to chris H   
   Re: Unable to query xml data in sql serv   
   11 Jun 20 00:15:05   
   
   From: esquel@sommarskog.se   
      
   chris H (chris.sjpd@gmail.com) writes:   
   > That is a complete xml file.  When I doubleclick to open it, it does not   
   have root tag.   
   >   
      
   I would say it's not an XML file then. An XML file has exactly a single root   
   tag. SQL Server supports repeated root tags, but there are no root tags at all   
   here.   
      
   I get this error from sp_xml_preparedocument:   
      
   Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1 [Batch   
   Start Line 0]   
   The error description is 'Only one top level element is allowed in an XML   
   document.'.   
      
      
   DECLARE @x xml =   
   ' 2020-200320523   
    1493 CRESTHAVEN LN,SAN JOSE, CA,  95118   
    1   
    1   
    1   
    02-01-2020   
    1547'   
      
   DECLARE @hDoc int   
   EXEC sp_xml_preparedocument @hDoc OUTPUT, @x   
      
      
    SELECT *   
   FROM OPENXML(@hDoc, '/', 1)   
   WITH   
   (   
   	[AccidentReportNumber-AllPages] varchar(20),   
       AddressFullText varchar(100) '/trafficunit/driver',   
       "InjuredWas_driver" int '/involvedPeople',   
       [PedestrianActionA-AllPages] int,   
       [MotorVehicleInvolvedWithC-AllPages] int,   
       [CollisionOccurredDate-AllPages]  date,   
       [Time-AllPages]  int   
   )   
      
   EXEC sp_xml_removedocument @hDoc OUTPUT   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca