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,310 of 19,505    |
|    chris to All    |
|    Re: Unable to query xml data in sql serv    |
|    17 Jun 20 13:13:41    |
   
   From: chris.sjpd@gmail.com   
      
   Hi Erland,   
      
   Could you please be more specific on how to read xml data in multiple xml   
   files given all of the xml files have the same structure?   
      
   My below query only works for a single xml file, but I need to query the data   
   from a bunch of files.   
      
      
   declare @x xml = (select xmldata from xmltbl)   
   SELECT Agency.a.value('(AccidentReportNumber-AllPages/text())[1]',   
   'varchar(20)') AS [AccidentReportNumber],   
    Agency.a.value('(CollisionOccurredDate-AllPages/text())[1]',   
   'varchar(20)') AS [CollisionOccurredDate],   
    Agency.a.value('(Time-AllPages/text())[1]', 'varchar(20)') AS [Time],   
    Agency.a.value('(MotorVehicleInvolvedWithI-AllPages/text())[1]',   
   'varchar(20)') AS [MotorVehicleInvolvedWithI],   
    Agency.a.value('(PedestrianActionA-AllPages/text())[1]',   
   'varchar(20)') AS [PedestrianAction],   
    Agency.a.value('(NumberInjured-AllPages/text())[1]', 'varchar(20)')   
   AS [NumberInjured],   
    Driver.d.value('(AddressFullText/text())[1]','nvarchar(60)') AS   
   AddressFullText   
   FROM @x.nodes('/agency') AS Agency(a)   
   CROSS APPLY Agency.a.nodes('TrafficUnit[TrafficUnit_Number="2"]/Driver') AS   
   Driver(d)   
      
   I really appreciate your helps/inputs.   
      
   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