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,317 of 19,505   
   chris to All   
   Re: Unable to query xml data in sql serv   
   13 Jul 20 14:25:59   
   
   From: chris.sjpd@gmail.com   
      
   Hi Erland,   
      
   When I execute the below sql query, I get the error:   
      
   DECLARE @x xml  =  (select xmldata from xmltbl)   
    SELECT Agency.a.value('(AccidentReportNumber-AllPages/text())[1]',   
   'varchar(20)') AS [AccidentReportNumber],   
           Agency.a.value('(NumberInjured-AllPages/text())[1]', 'varchar(20)') AS   
   [NumberInjured],   
           Driver.d.value('(AddressFullText/text())[1]','nvarchar(60)') AS   
   AddressFullText   
    FROM  xmltbl   
    CROSS APPLY xmldata.nodes('/agency') AS Agency(a)   
    CROSS  APPLY Agency.a.nodes('TrafficUnit[TrafficUnit_Number="2"]/Driver') AS   
   Driver(d)   
      
   Errors:   
   ========   
   Msg 512, Level 16, State 1, Line 6   
   Subquery returned more than 1 value. This is not permitted when the subquery   
   follows =, !=, <, <= , >, >= or when the subquery is used as an expression.   
      
   How do I get rid of this error & get the query to return correct output?   
      
   Thank you,   
   Chris   
      
   --- 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